我正在尝试通过laravel中的邮件队列从php发送通知邮件,据我所知一切正常,我已经在我的个人邮件acc上测试了配置。但是当我尝试通过smtp服务器发送邮件时,它失败并显示以下错误。
环境中的邮件配置。 :
MAIL_DRIVER=smtp
MAIL_HOST= smtp.server.address
MAIL_PORT=25
mail.php中的邮件配置:
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'mailrelay.vaillant.vhgroup.lan'),
'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),
有效载荷:
{"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:\"hascicm.mh@gmail.com\";}}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\r\n', Array, Array, false, NULL)
#2 /var/www/ctstest/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(390): Swift_Transport_EsmtpTransport->executeCommand('DATA\r\n', 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): Illuminate\Mail\Mailer->sendSwiftMessage(Object(Swift_Message))
#9 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php(148): Illuminate\Mail\Mailer->send('emails.unplanne...', Array, Object(Closure))
#10 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php(18): Illuminate\Mail\Mailable->Illuminate\Mail\{closure}()
#11 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php(149): Illuminate\Mail\Mailable->withLocale(NULL, Object(Illuminate\Translation\Translator), Object(Closure))
#12 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Mail/SendQueuedMailable.php(52): Illuminate\Mail\Mailable->send(Object(Illuminate\Mail\Mailer))
#13 [internal function]: Illuminate\Mail\SendQueuedMailable->handle(Object(Illuminate\Mail\Mailer))
#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): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#16 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#17 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#18 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
#19 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(Illuminate\Mail\SendQueuedMailable))
#20 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Mail\SendQueuedMailable))
#21 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#22 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(Illuminate\Mail\SendQueuedMailable), false)
#23 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(83): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)
#24 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(326): Illuminate\Queue\Jobs\Job->fire()
#25 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(276): Illuminate\Queue\Worker->process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), Object(Illuminate\Queue\WorkerOptions))
#26 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\DatabaseJob), 'database', Object(Illuminate\Queue\WorkerOptions))
#27 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#28 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'default')
#29 [internal function]: Illuminate\Queue\Console\WorkCommand->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): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#32 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#33 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#34 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Console/Command.php(179): Illuminate\Container\Container->call(Array)
#35 /var/www/ctstest/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#36 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Console/Command.php(166): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#37 /var/www/ctstest/vendor/symfony/console/Application.php(886): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#38 /var/www/ctstest/vendor/symfony/console/Application.php(262): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#39 /var/www/ctstest/vendor/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#40 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Console/Application.php(89): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#41 /var/www/ctstest/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#42 /var/www/ctstest/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#43 {main}
答案 0 :(得分:3)
我长期遇到相同的问题,但是我已经解决了
您在本地服务中,例如xampp或wampp等
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=test@gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl
但是当您进入实时服务器时
MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=test@gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl
只需将邮件驱动程序更改为sendmail
,我不知道它是如何工作的,但是它修复了我的server-error-503
答案 1 :(得分:1)
我遇到了同样的问题,并通过更改端口来解决了这个问题。
如果您使用的是 SSL 或 TLS ,请使用 587 作为端口,而不是25。
希望获得帮助。
答案 2 :(得分:1)
此错误的三个最常见原因是:
错误503通常会告诉您,您需要在电子邮件客户端中设置SMTP身份验证。
在Laravel中,您可以捕获此错误并显示类似这样的错误消息,
try {
Mail::send('emails.contact-message', [
'msg' => $request->body,
'name' => $request->name,
'email' => $request->email,
],
function ($mail) use($request) {
$mail->from($request->email, $request->name);
$mail->to('support@domain.com')->subject('Contact Message');
}
);
// Catch the error
} catch(\Swift_TransportException $e){
if($e->getMessage()) {
dd($e->getMessage());
}
}
答案 3 :(得分:0)
将配置详细信息放入.env文件
例如。
MAIL_DRIVER=smtp
MAIL_HOST=smtp.server.address
MAIL_PORT=465
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=null
然后重新启动工匠并进行测试
答案 4 :(得分:0)
更改for index,row in df.iterrows():
y = some_function(index,row)
print(y)
文件中的这一行:
autocov
收件人:
def autocov(row):
x = sm.tsa.stattools.acovf(df.T[row], unbiased=False, demean=True,
fft=None, missing='none')
autocov_df = pd.DataFrame(x)
return(autocov_df)
for index,row in df.iterrows():
x = autocov(index)
print(x)
答案 5 :(得分:0)
如果您通过.env中与EMAIL_USERNAME相同的主机名发送邮件,但主机服务器中不存在该邮件。您收到该错误。即
如果EMAIL_USERNAME: themail@yourhost.com ,则mail_from是这样的-> from('no-reply@yourhost.com')和no-reply @ yourhost.com不存在。
摘要
从诸如“ no-reply@yourhost.com”之类的邮件地址发送电子邮件或任何其他邮件;重要的是您已经在服务器或面板上创建了该邮件,否则会引发错误:“ 503-所有RCPT命令均被拒绝,并显示此错误:503-发件人验证失败503有效RCPT命令必须在数据之前”
答案 6 :(得分:0)
这是.env配置文件:
MAIL_DRIVER=smtp
MAIL_HOST= smtp.server.address
MAIL_PORT=25
MAIL_USERNAME=Your smtp username (if exists)
MAIL_PASSWORD=Your smtp password (if exists)
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=your email smtp address
MAIL_FROM_NAME=your name
但是您应该检查smpt服务器的正确参数。如果您愿意,我可以帮助您。
答案 7 :(得分:0)
面对同样的问题,结果发现发件人电子邮件不存在。
我能够重现以下问题:
$sender_email = "non.existing@gmail.com";
$receiver_email = "existing@gmail.com";
Mail::raw("Email content", function($message) use ($sender_email, $receiver_email) {
$message->from($sender_email, config('app.name'));
$message->to($receiver_email)->subject("Email subject");
});
如果您未明确指定$message->from
并且MAIL_FROM_ADDRESS
中的app/config.php
是空电子邮件或不存在电子邮件,也会发生此问题。