Laravel SwiftMailer:预期响应代码为 250,但得到代码“530",消息为“530-5.5.1 需要身份验证"

2021-12-18 00:00:00 php laravel swiftmailer laravel-5.2

我正在使用 laravel 5.2,并且使用 Swift Mailer 进行密码重置.我的 Gmail 有两步验证..

I am using laravel 5.2, And the using Swift Mailer for password resetting. I have 2-step verification on my gmail..

正如谷歌帮助所说:

如果您为自己的帐户启用了两步验证,则可能需要输入应用密码而不是常规密码.

If you've turned on 2-Step Verification for your account, you might need to enter an App password instead of your regular password.

我在 mail.php 上有以下设置:

I have the following settings on mail.php :

return [
    'driver' => env('MAIL_DRIVER', 'smtp'),
    'host' => env('MAIL_HOST', 'smtp.gmail.com'),
    'port' => env('MAIL_PORT', 465),
    'from' => ['address' => 'meaprogrammer@gmail.com', 'name' => 'Shafee'],
    'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
    'username' => env('meaprogrammer@gmail.com'),
    'password' => env('MY_Gmail_API_KEY'),
    'sendmail' => '/usr/sbin/sendmail -bs',
    'pretend' => env('MAIL_PRETEND', false),

];

.env 我有:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=meaprogrammer@gmail.com
MAIL_PASSWORD=MY_Gmail_API_KEY
MAIL_ENCRYPTION=ssl

出现以下错误:

Swift_TransportException in AbstractSmtpTransport.php line 383:

Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required. 

Learn more at
530 5.5.1 https://support.google.com/mail/answer/14257 w10sm15831823wjk.18 - gsmtp
"

推荐答案

尝试在 此页面.阅读这个谷歌答案.

相关文章