预期的响应代码为250,但代码为"530",消息为"530-5.5.1",需要身份验证 [英] Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required

查看:254
本文介绍了预期的响应代码为250,但代码为"530",消息为"530-5.5.1",需要身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向注册用户发送电子邮件验证,但出现以下错误:

I am trying to send an email verification for the registering users but I am getting the following error:

预期的响应代码为250,但得到的代码为"530",并显示消息"530-5.5.1" 需要验证.在\ r \ n 530 5.5.1了解更多信息 https://support.google.com/mail/?p=WantAuthError v11sm5345109pgt .0- gsmtp \ r \ n

Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required. Learn more at\r\n 530 5.5.1 https://support.google.com/mail/?p=WantAuthError v11sm5345109pgt.0 - gsmtp\r\n

我通过启用安全性较低"和其他说明尝试了所有可能的方法,但并未理解错误.请帮助我解决问题.

I have tried all the possible ways by enabling the "less secure" and other instructions but not understanding the error. please help me to sort out the problem.

我的.env文件是:

我的控制器:

我的mail.php:

My mail.php:

'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => env('MAIL_FROM_ADDRESS', 'myaccount@gmail.com'),
        'name' => env('MAIL_FROM_NAME', 'Example'), ],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('myaccount@gmail.com'),
'password' => env('*******'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => FALSE,

推荐答案

问题出在您的mail.php中,请使用此代码代替您的

The problem is in your mail.php, use this code instead of your

...
'driver' => env('MAIL_DRIVER', 'smtp'),
'host'   => env('MAIL_HOST', 'smtp.gmail.com'),
'port'   => env('MAIL_PORT', 587),
'from'   => [
   'address' => env('MAIL_FROM_ADDRESS', 'myaccount@gmail.com'),
   'name' => env('MAIL_FROM_NAME', 'Example')
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME', 'myaccount@gmail.com'),
'password' => env('MAIL_PASSWORD', '*******'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => FALSE,
...

env()辅助方法的第一个参数是name of environment variable,如果找不到该变量,则第二个参数是后备值.之所以不起作用,是因为Laravel无法找到名称为myaccount@gmail.com*******environment变量.

First parameter of the env() helper method is name of environment variable and second one is a fallback value if that variable isn't found. The reason why it didn't work is because Laravel wasn't able to find an environment variable under the name myaccount@gmail.com and *******.

这篇关于预期的响应代码为250,但代码为"530",消息为"530-5.5.1",需要身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆