Create a mail translation.

@param MailInterface $mail   The mail
@param array         $config The config of mail translation

@return MailTranslationInterface
334043
protected function createMailTranslation(MailInterface $mail, array $config)
    {
        $translation = $this->newMailTranslationInstance($mail);
        $translation->setLocale(ConfigUtil::getValue($config, 'locale'));
        $translation->setLabel(ConfigUtil::getValue($config, 'label'));
        $translation->setDescription(ConfigUtil::getValue($config, 'description'));
        $translation->setSubject(ConfigUtil::getValue($config, 'subject'));
        $translation->setHtmlBody(ConfigUtil::getValue($config, 'html_body'));
        $translation->setBody(ConfigUtil::getValue($config, 'body'));

        return $translation;
    }
46610
public function getMessage($config = null)
    {
        if ($config && !$config instanceof ConfigObject) {
            $config = new ConfigObject($config);
        }
        return Loader::getMessage($this->mailerName, $config);
    }
1019564
private function getCurrentMailer(array $config)
    {
        if ($this->mailer !== null) {
            return $this->mailer;
        }

        $swiftVersion = (int) explode('.', \Swift::VERSION)[0];

        if ($config['mailer'] === 'smtp') {
            $transport = new \Swift_SmtpTransport(
                $config['smtpHost'],
                $config['smtpPort'],
                $config['smtpSecurity']
            );
            $transport->setUsername($config['smtpUsername']);
            $transport->setPassword($config['smtpPassword']);
        } elseif ($swiftVersion < 6 && $config['mailer'] === 'mail') {
            $transport = \Swift_MailTransport::newInstance();
        } else {
            $transport = new \Swift_SendmailTransport();
        }

        return new \Swift_Mailer($transport);
    }
228480
public function to($mail, $name = null)
    {
        $this->mailer->addAddress($mail, $name);
        return $this;
    }
225724
public function addTranslation(TranslationInterface $translation)
    {
        if (!$this->translations->contains($translation)) {
            $this->translations[$translation->getLocale()] = $translation;
            $translation->setTranslatable($this);
        }
    
        return $this;
    }
855682
public function translate($message)
    {
        $locale = $this->configuration
            ->get('i18n.locale', $this->fallbackLocale);

        return $this->getTranslatorService()
            ->translate($message, $this->domain, $locale);
    }
1127338
public static function fromConfig(array $config, string $language): Translator {
        $translations = (new Processor())->
            processConfiguration(new TranslatorConfiguration(), [$config]);

        return new static($translations, $language);
    }
87460
public function mailto($content, $mail, array $options = []) {
        if ($content === $mail) {
            throw new \RuntimeException('El contenido no debe ser una direcci&oacute;n de email, pruebe "Contacteme"');
        }
        $data = explode('@', $mail);
        
        $user = $data[0];
        $server = key_exists(1, $data) ? explode('.', $data[1]) : [];
        
        $config = [
            'onclick' => 'this.href=\'mailto:\' + \'' 
                . $user . '\' + \'@\' + \'' 
                . (key_exists(0, $server) ? $server[0] : '') . '\' + \'.\' + \''
                . (key_exists(1, $server) ? $server[1] : '') . '\'',
            'rel' => 'nofollow'
        ] + $options;
        
        return $this->link($content, '', $config);
    }
854012
public static function t($message, $args = [], $domain = 'core', $locale = 'en_EN')
    {
        return self::getInstance()->translator->trans($message, $args, $domain, $locale);
    }
1300416
public function from($mail, $name)
    {
        $this->_sender_name = $name;
        $this->_sender_mail = $mail;

        return $this;
    }
145641
private static function createConfiguration(array $config, ContainerInterface $container = null)
    {
        $cache = $config['cache'];

        if ($container && is_string($config['cache']) && $container->has($config['cache'])) {
            $cache = $container->get($config['cache']);
        }

        return Setup::createConfiguration($config['debug'], $config['proxy_dir'], $cache);
    }
44862
public function message($message, $config = array())
    {
        $config = new AnConfig($config);

        $config->append(array(
            'type' => 'info',
            'block' => true,
            'closable' => false,
        ));

        $alertblock = ($config->block) ? 'alert-block' : '';

        $close_handler = '';
        if ($config->closable) {
            $close_handler = '<a class="close" data-dismiss="alert">&times;</a>';
        }

        $message = AnTranslator::_($message);

        return "<div class=\"alert alert-{$config->type} $alertblock\">$close_handler<p>$message</p></div>";
    }
342068
protected function setMetaboxTranslations(MetaboxInterface $metabox)
    {
        if (! function_exists('__')) {
            return $this;
        }

        $metabox->addTranslation('done', __('Saved', Application::TEXTDOMAIN));
        $metabox->addTranslation('error', __('Saved with errors', Application::TEXTDOMAIN));
        $metabox->addTranslation('saving', __('Saving', Application::TEXTDOMAIN));
        $metabox->addTranslation('submit', sprintf('%s %s', __('Save', Application::TEXTDOMAIN), $metabox->getTitle()));

        return $this;
    }
140485
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('Config');
        $options = new SmtpOptions(isset($config['mail']['transport']['options'])
            ? $config['mail']['transport']['options']
            : []
        );
        return (new Smtp())->setOptions($options);
    }
924918
public function to($mail, $name = null)
    {
        $this->message->addTo($mail, $name);
        return $this;
    }
977547
protected function composeMessage($notification)
    {
        if(empty($this->message['to'])){
            throw new InvalidConfigException('The "to" option must be set in EmailChannel::message.');
        }
        $message = $this->mailer->compose();
        Yii::configure($message, $this->message);
        $message->setSubject((string)$notification->getTitle());
        $message->setTextBody((string)$notification->getDescription());
        return $message;
    }
462731
public function translate($message, array $params = array())
    {
        // Update the current message with the domain translation, if we have one.
        if (isset($this->messages[$message]) && ! empty($this->messages[$message])) {
            $message = $this->messages[$message];
        }

        if (empty($params)) {
            return $message;
        }

        $formatter = new MessageFormatter();

        return $formatter->format($message, $params, $this->locale);
    }