M
M
Mikha Pankratov2015-10-29 15:00:45
Yii
Mikha Pankratov, 2015-10-29 15:00:45

Why is sending mail not working on yii2?

Good afternoon,
Previously, everything worked and then abruptly stopped checking passwords, but still writes an error 500 when sending mail to firebug. show my
web.php code

'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.mail.ru',
                'username' => '######@bk.ru',
                'password' => '#####',
                'port' => '587',
                'encryption' => 'tls',
            ],
        ],

controller
Yii::$app->mailer->compose()
            ->setFrom('#####@bk.ru')
            ->setTo('###@gmail.com')
            ->setSubject('####.ru - Новый клиент - '.$name)
            ->setTextBody('Plain text content')
            ->setHtmlBody($body)
            ->send();

access log
31.132.0.0 - - [29/Oct/2015:08:03:23 -0400] "POST /index.php?r=site/send-contact HTTP/1.1" 500 327 " http://##### .ru/ " "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/45.0.2454.101 Chrome/45.0$

and log applications

2015-10-29 12:03:24 [31.132.176.118][-][-][error][Swift_TransportException] exception 'Swift_TransportException' with message 'Expected response code 250 but got code "550", with message "550 Message was not accepted -- invalid mailbox.$
"' in /home/git/projects/site/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:383
Stack trace:
#0 /home/git/ projects/site/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(281): Swift_Transport_AbstractSmtpTransport->_assertResponseCode('550 Message was...', Array)
#1 /home/git/projects/ site/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(243): Swift_Transport_AbstractSmtpTransport->executeCommand('\r\n.\r\n', Array, Array)
#2 /home/git/projects/site/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(333): Swift_Transport_EsmtpTransport->executeCommand('\r\n.\r\n', Array )
#3 /home/git/projects/site/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(428): Swift_Transport_AbstractSmtpTransport->_streamMessage(Object(Swift_Message))
#4 /home/git/ projects/site/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(444): Swift_Transport_AbstractSmtpTransport->_doMailTransaction(Object(Swift_Message), '[email protected]', Array, Arra$
#5 /home/git/projects/site/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(176): Swift_Transport_AbstractSmtpTransport->_sendTo(Object(Swift_Message), '[email protected] .', Array, Array)
#6 /home/git/projects/site/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php(85): Swift_Transport_AbstractSmtpTransport->send(Object(Swift_Message), Array)
# 7 /home/git/projects/site//vendor/yiisoft/yii2-swiftmailer/Mailer.php(140): Swift_Mailer->send(Object(Swift_Message))
#8 /home/git/projects/site//vendor/ yiisoft/yii2/mail/BaseMailer.php(260): yii\swiftmailer\Mailer->sendMessage(Object(yii\swiftmailer\Message))
#9 /home/git/projects/site//vendor/yiisoft/yii2/mail /BaseMessage.php(48): yii\mail\BaseMailer->send(Object(yii\swiftmailer\Message))
#10 /home/git/projects/site//controllers/SiteController.php(111): yii\mail\BaseMessage->send()
#11 [internal function]: app\controllers\SiteController->actionSendContact()
#12 /home/git/projects/site//vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)
#13 /home/git/projects/site//vendor/yiisoft/yii2/base /Controller.php(151): yii\base\InlineAction->runWithParams(Array)
#14 Controller->runAction('send-contact', Array)
#15 /home/git/projects/site//vendor/yiisoft/yii2/web/Application.php(83): yii\base\Module->runAction(' site/send-conta...', Array)
#16 /home/git/projects/site//vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#17 /home/ git/projects/site//web/index.php(12): yii\base\Application->run()
#18 {main}

I hope someone will tell you, maybe htaccess is necessary? Can with apache2 that happened, I will not understand in any way. Thanks everyone will help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2015-10-29
@frmax

so you have code 500 - look at the application logs and not the apache.

S
Slava Vitrenko, 2016-06-05
@bagiroff777

550 Message was not accepted -- invalid mailbox
Most likely an error in the email address

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question