本文介绍了预期的响应代码为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:

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

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', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'Example'), ],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('[email protected]'),
'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', '[email protected]'),
   'name' => env('MAIL_FROM_NAME', 'Example')
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME', '[email protected]'),
'password' => env('MAIL_PASSWORD', '*******'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => FALSE,
...

env()辅助方法的第一个参数是name of environment variable,如果找不到该变量,则第二个参数是后备值.之所以不起作用,是因为Laravel无法找到名称为[email protected]*******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 [email protected] and *******.

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

07-24 01:41