Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
593 views
in Technique[技术] by (71.8m points)

php - Laravel mail sending through smtp server error 503 5.5.2

I am trying to send notification mails from php through mail queue in laravel, as far as i can tell everything works fine, i have already tested configuration on my personal mail acc. but when i try sending mail through smtp server it fails with following error.

mail config in env. :

MAIL_DRIVER=smtp
MAIL_HOST= smtp.server.address
MAIL_PORT=25

mail config in mail.php :

'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.server.address'),
'port' => env('MAIL_PORT', 25),
'sendmail' => '/usr/sbin/sendmail -bs',
'stream' => [
    'ssl' => [
        'allow_self_signed' => true,
        'verify_peer' => false,
        'verify_peer_name' => false,
    ],
],
'markdown' => [
    'theme' => 'default',

    'paths' => [
        resource_path('views/vendor/mail'),
    ],
],
'pretend' => env('MAIL_PRETEND', false),

payload:

{"displayName":"cts\Mail\UnplanedNotification","job":"Illuminate\Queue\CallQueuedHandler@call","maxTries":null,"timeout":null,"timeoutAt":null,"data":{"commandName":"Illuminate\Mail\SendQueuedMailable","command":"O:34:"Illuminate\Mail\SendQueuedMailable":3:{s:8:"mailable";O:29:"cts\Mail\UnplanedNotification":22:{s:9:"u0000*u0000rework";a:21:{s:12:"complaint_id";i:4184;}}}s:6:"locale";N;s:4:"from";a:0:{}s:2:"to";a:1:{i:0;a:2:{s:4:"name";N;s:7:"address";s:20:"[email protected]";}}s:2:"cc";a:0:{}s:3:"bcc";a:0:{}s:7:"replyTo";a:0:{}s:7:"subject";N;s:11:"u0000*u0000markdown";N;s:7:"u0000*u0000html";N;s:4:"view";N;s:8:"textView";N;s:8:"viewData";a:0:{}s:11:"attachments";a:0:{}s:14:"rawAttachments";a:0:{}s:9:"callbacks";a:0:{}s:10:"connection";N;s:5:"queue";N;s:15:"chainConnection";N;s:10:"chainQueue";N;s:5:"delay";N;s:7:"chained";a:0:{}}s:5:"tries";N;s:7:"timeout";N;}"}}

Stacktrace:

Swift_TransportException: Expected response code 354 but got code "503", with message "503 5.5.2 Need rcpt command
" in /var/www/ctstest/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:457
Stack trace:
#0 /var/www/ctstest/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(341): Swift_Transport_AbstractSmtpTransport->assertResponseCode('503 5.5.2 Need ...', Array)
#1 /var/www/ctstest/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(305): Swift_Transport_AbstractSmtpTransport->executeCommand('DATA
', Array, Array, false, NULL)
#2 /var/www/ctstest/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(390): Swift_Transport_EsmtpTransport->executeCommand('DATA
', Array, Array)
#3 /var/www/ctstest/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(497): Swift_Transport_AbstractSmtpTransport->doDataCommand(Array)
#4 /var/www/ctstest/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(516): Swift_Transport_AbstractSmtpTransport->doMailTransaction(Object(Swift_Message), 'deamon_do_not_r...', Array, Array)
#5 /var/www/ctstest/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(206): Swift_Transport_AbstractSmtpTransport->sendTo(Object(Swift_Message), 'deamon_do_not_r...', Array, Array)
#6 /var/www/ctstest/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php(71): Swift_Transport_AbstractSmtpTransport->send(Object(Swift_Message), Array)
#7 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(464): Swift_Mailer->send(Object(Swift_Message), Array)
#8 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(248): IlluminateMailMailer->sendSwiftMessage(Object(Swift_Message))
#9 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php(148): IlluminateMailMailer->send('emails.unplanne...', Array, Object(Closure))
#10 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php(18): IlluminateMailMailable->IlluminateMail{closure}()
#11 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php(149): IlluminateMailMailable->withLocale(NULL, Object(IlluminateTranslationTranslator), Object(Closure))
#12 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Mail/SendQueuedMailable.php(52): IlluminateMailMailable->send(Object(IlluminateMailMailer))
#13 [internal function]: IlluminateMailSendQueuedMailable->handle(Object(IlluminateMailMailer))
#14 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#15 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): IlluminateContainerBoundMethod::IlluminateContainer{closure}()
#16 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): IlluminateContainerBoundMethod::callBoundMethod(Object(IlluminateFoundationApplication), Array, Object(Closure))
#17 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): IlluminateContainerBoundMethod::call(Object(IlluminateFoundationApplication), Array, Array, NULL)
#18 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): IlluminateContainerContainer->call(Array)
#19 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): IlluminateBusDispatcher->IlluminateBus{closure}(Object(IlluminateMailSendQueuedMailable))
#20 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): IlluminatePipelinePipeline->IlluminatePipeline{closure}(Object(IlluminateMailSendQueuedMailable))
#21 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): IlluminatePipelinePipeline->then(Object(Closure))
#22 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(49): IlluminateBusDispatcher->dispatchNow(Object(IlluminateMailSendQueuedMailable), false)
#23 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(83): IlluminateQueueCallQueuedHandler->call(Object(IlluminateQueueJobsDatabaseJob), Array)
#24 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(326): IlluminateQueueJobsJob->fire()
#25 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(276): IlluminateQueueWorker->process('database', Object(IlluminateQueueJobsDatabaseJob), Object(IlluminateQueueWorkerOptions))
#26 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): IlluminateQueueWorker->runJob(Object(IlluminateQueueJobsDatabaseJob), 'database', Object(IlluminateQueueWorkerOptions))
#27 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): IlluminateQueueWorker->daemon('database', 'default', Object(IlluminateQueueWorkerOptions))
#28 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85): IlluminateQueueConsoleWorkCommand->runWorker('database', 'default')
#29 [internal function]: IlluminateQueueConsoleWorkCommand->handle()
#30 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#31 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): IlluminateContainerBoundMethod::IlluminateContainer{closure}()
#32 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): IlluminateContainerBoundMethod::callBoundMethod(Object(IlluminateFoundationApplication), Array, Object(Closure))
#33 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): IlluminateContainerBoundMethod::call(Object(IlluminateFoundationApplication), Array, Array, NULL)
#34 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Console/Command.php(179): IlluminateContainerContainer->call(Array)
#35 /var/www/ctstest/vendor/symfony/console/Command/Command.php(255): IlluminateConsoleCommand->execute(Object(SymfonyComponentConsoleInputArgvInput), Object(IlluminateConsoleOutputStyle))
#36 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Console/Command.php(166): SymfonyComponentConsoleCommandCommand->run(Object(SymfonyComponentConsoleInputArgvInput), Object(IlluminateConsoleOutputStyle))
#37 /var/www/ctstest/vendor/symfony/console/Application.php(886): IlluminateConsoleCommand->run(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#38 /var/www/ctstest/vendor/symfony/console/Application.php(262): SymfonyComponentConsoleApplication->doRunCommand(Object(IlluminateQueueConsoleWorkCommand), Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#39 /var/www/ctstest/vendor/symfony/console/Application.php(145): SymfonyComponentConsoleApplication->doRun(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#40 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Console/Application.php(89): SymfonyComponentConsoleApplication->run(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#41 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): IlluminateConsoleApplication->run(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#42 /var/www/ctstest/artisan(37): IlluminateFoundationConsoleKernel->handle(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#43 {main}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

i had the same issue long time but i have fixed it

While you are in the local serve ie) xampp or wampp etc

MAIL_DRIVER=smtp


MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl

but when you are going in live server

MAIL_DRIVER=sendmail


MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl

Just Change the mail driver to sendmail I have no idea how its is working but it fixed my server-error-503


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...