public static function getMessage($mailer, ConfigObject $config = null)
    {
        // Do it this way to avoid merging into the original mailer config
        $mailerConfig = Mailer::getConfig()->get($mailer)->toArray();
        $mailerConfig = new ConfigObject($mailerConfig);
        if ($config) {
            $mailerConfig->mergeWith($config);
        }
        $lib = self::getLibrary($mailer);

        /** @var MailerInterface $libInstance */
        $libInstance = self::factory($lib, MailerInterface::class);

        $instance = $libInstance::getMessage($mailerConfig);
        if (!self::isInstanceOf($instance, MessageInterface::class)) {
            throw new MailerException(MailerException::MESSAGE_INTERFACE);
        }

        return $instance;
    }