Answer the question
In order to leave comments, you need to log in
How to make swiftmailer work from console controller in Yii2?
Applications are created on the portal. When an application is created, it-administrators are sent emails. At first there was an option when the mailing function was performed right in the action when creating an application:
Yii::$app->mailer->compose('newtaskcreated', [ //шаблон письма
'model' => $this
]) ->setTo($mass_email) // массив адресов
->setSubject("Портал Yii2 - Новая заявка, №".$this->id)
->send();
Exception 'Swift_TransportException' with message 'Expected response code 220 but got code "", with message ""'
in /var/www/it2/basic_yii/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:419
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => false,
'viewPath' => '@app/mail',
'htmlLayout' => 'layouts/html',
'messageConfig' => [
'charset' => 'UTF-8',
'from' => ['[email protected]' => 'XXXXXX'],
],
// данные для YANDEX sftp
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.yandex.ru',
'username' => '[email protected]',
'password' => 'XXXXXX',
'port' => '465',
'encryption' => 'ssl',
],
],
Answer the question
In order to leave comments, you need to log in
most likely in your console application configuration (in the config/console.php file) the mailer component is not defined or not configured correctly
If the server is running on nginx, then you can quickly send from the browser
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question