laravel队列守护程序邮件因SSL错误而停止运行

时间:2014-07-30 20:07:21

标签: php email ssl laravel laravel-4

我正在运行一个laravel队列守护程序,它根据所采取的操作发送邮件。这是通过主管运行以确保它始终运行。它起初工作正常,但一段时间后邮件停止发送。该错误未报告链,但日志显示:

[2014-07-30 20:00:21] production.ERROR: exception 'ErrorException' with message 'fwrite(): SSL operation failed with code 1. OpenSSL Error messages:
error:1409F07F:SSL routines:SSL3_WRITE_PENDING:bad write retry' in /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:232
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleError(2, 'fwrite(): SSL o...', '/srv/www/example...', 232, Array)
#1 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php(232): fwrite(Resource id #376, 'MAIL FROM: <hel...')
#2 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php(171): Swift_Transport_StreamBuffer->_commit('MAIL FROM: <hel...')
#3 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php(90): Swift_ByteStream_AbstractFilterableInputStream->_doWrite('MAIL FROM: <hel...')
#4 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(274): Swift_ByteStream_AbstractFilterableInputStream->write('MAIL FROM: <hel...')
#5 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(243): Swift_Transport_AbstractSmtpTransport->executeCommand('MAIL FROM: <hel...', Array, Array)
#6 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(323): Swift_Transport_EsmtpTransport->executeCommand('MAIL FROM: <hel...', Array)
#7 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(416): Swift_Transport_EsmtpTransport->_doMailFromCommand('hello@example.co...')
#8 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(444): Swift_Transport_AbstractSmtpTransport->_doMailTransaction(Object(Swift_Message), 'hello@example.co...', Array, Array)
#9 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(174): Swift_Transport_AbstractSmtpTransport->_sendTo(Object(Swift_Message), 'hello@example.co...', Array, Array)
#10 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php(85): Swift_Transport_AbstractSmtpTransport->send(Object(Swift_Message), Array)
#11 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(328): Swift_Mailer->send(Object(Swift_Message), Array)
#12 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(150): Illuminate\Mail\Mailer->sendSwiftMessage(Object(Swift_Message))
#13 /srv/www/example.co.uk/bootstrap/compiled.php(3231): Illuminate\Mail\Mailer->send('emails.campaign...', Array, Object(Closure))
#14 /srv/www/example.co.uk/app/commands/Sender.php(252): Illuminate\Support\Facades\Facade::__callStatic('send', Array)
#15 /srv/www/example.co.uk/app/commands/Sender.php(252): Illuminate\Support\Facades\Mail::send('emails.campaign...', Array, Object(Closure))
#16 /srv/www/example.co.uk/app/commands/Sender.php(116): Sender->_sendEmail(Array, Array, Array, Array)
#17 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(96): Sender->queue(Object(Illuminate\Queue\Jobs\RedisJob), Array)
#18 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Jobs/RedisJob.php(46): Illuminate\Queue\Jobs\Job->resolveAndFire(Array)
#19 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(192): Illuminate\Queue\Jobs\RedisJob->fire()
#20 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(142): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), '2', 0)
#21 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(101): Illuminate\Queue\Worker->pop('redis', NULL, 0, '3', '2')
#22 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(73): Illuminate\Queue\Worker->runNextJobForDaemon('redis', NULL, 0, '3', '2')
#23 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(98): Illuminate\Queue\Worker->daemon('redis', NULL, 0, 128, '3', '2')
#24 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(68): Illuminate\Queue\Console\WorkCommand->runWorker('redis', NULL, 0, 128, true)
#25 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Console/Command.php(112): Illuminate\Queue\Console\WorkCommand->fire()
#26 /srv/www/example.co.uk/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(252): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Console/Command.php(100): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 /srv/www/example.co.uk/vendor/symfony/console/Symfony/Component/Console/Application.php(887): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#29 /srv/www/example.co.uk/vendor/symfony/console/Symfony/Component/Console/Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 /srv/www/example.co.uk/vendor/symfony/console/Symfony/Component/Console/Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /srv/www/example.co.uk/artisan(59): Symfony\Component\Console\Application->run()
#32 {main} [] []

我很想得到什么想法?我使用sendgrid进行邮寄

编辑,与此处相同:https://github.com/swiftmailer/swiftmailer/issues/490

1 个答案:

答案 0 :(得分:1)

这是Laravel / Swift中的一个错误,以及它在长时间运行的队列工作程序中处理它的套接字的方式。避免此问题的最佳方法是确保在发送每封电子邮件后关闭传输。

Laravel的bug追踪器中有一个closed issue,它有一些Laravel代码库补丁可以解决这个问题。

或者,查看YOzaz/Laravel-SwiftMailer包,它具有更新的邮件外观,最有可能解决您遇到的问题。