Laravel 5.1预期响应代码250,但得到代码“”,带有消息“”

时间:2017-09-14 19:30:17

标签: php laravel swiftmailer

使用google smtp通过swiftmailer发送电子邮件时,我收到此错误:

  

production.ERROR:Swift_TransportException:预期的响应代码250   但得到代码“”,消息“”在   的/ var / WWW /站点/供应商/ swiftmailer / swiftmailer / LIB /类/夫特/运输

堆栈追踪:

#0 /var/www/site/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(281): Swift_Transport_AbstractSmtpTransport->_assertResponseCode('', Array)
#1 /var/www/site/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(270): Swift_Transport_AbstractSmtpTransport->executeCommand('HELO [127.0.0.1...', Array, Array)
#2 /var/www/site/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(296): Swift_Transport_EsmtpTransport->executeCommand('HELO [127.0.0.1...', Array)
#3 /var/www/site/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(306): Swift_Transport_AbstractSmtpTransport->_doHeloCommand()
#4 /var/www/site/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(118): Swift_Transport_EsmtpTransport->_doHeloCommand()
#5 /var/www/site/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php(79): Swift_Transport_AbstractSmtpTransport->start()
#6 /var/www/site/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(394): Swift_Mailer->send(Object(Swift_Message), Array)
#7 /var/www/site/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(179): Illuminate\Mail\Mailer->sendSwiftMessage(Object(Swift_Message))
#8 /var/www/site/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(284): Illuminate\Mail\Mailer->send('email::lyceumLi...', Array, Object(Closure))
#9 /var/www/site/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(129): Illuminate\Mail\Mailer->handleQueuedMessage(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)
#10 /var/www/site/vendor/laravel/framework/src/Illuminate/Queue/Jobs/DatabaseJob.php(50): Illuminate\Queue\Jobs\Job->resolveAndFire(Array)
#11 /var/www/site/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(218): Illuminate\Queue\Jobs\DatabaseJob->fire()
#12 /var/www/site/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(159): Illuminate\Queue\Worker->process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), '0', '0')
#13 /var/www/site/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(108): Illuminate\Queue\Worker->pop('', 'default', '0', '3', '0')
#14 /var/www/site/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(70): Illuminate\Queue\Console\WorkCommand->runWorker('', 'default', '0', '128', false)
#15 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()
#16 /var/www/site/bootstrap/cache/compiled.php(1187): call_user_func_array(Array, Array)
#17 /var/www/site/vendor/laravel/framework/src/Illuminate/Console/Command.php(150): Illuminate\Container\Container->call(Array)
#18 /var/www/site/vendor/symfony/console/Command/Command.php(263): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\Cons$
#19 /var/www/site/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\C$
#20 /var/www/site/vendor/symfony/console/Application.php(872): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutpu$
#21 /var/www/site/vendor/symfony/console/Application.php(201): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Inpu$
#22 /var/www/site/vendor/symfony/console/Application.php(119): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output$
#23 /var/www/site/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Sym$
#24 /var/www/site/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 {main}

=============================================== =========================

使用laravel 5.1 .ENV:

MAIL_DRIVER=smtp 
MAIL_HOST=smtp-relay.gmail.com 
MAIL_PORT=25 
MAIL_USERNAME=username 
MAIL_PASSWORD=password
MAIL_ENCRYPTION=null

1 个答案:

答案 0 :(得分:0)

如何布置信息会出错。

MAIL_USERNAME应该换行。

像这样:

MAIL_DRIVER=smtp 
MAIL_HOST=smtp-relay.gmail.com 
MAIL_PORT=25
MAIL_USERNAME=username 
MAIL_PASSWORD=password
MAIL_ENCRYPTION=null