Laravel SwiftMailer:预期响应代码 250 但收到代码“530”,消息“530-5.5.1 需要身份验证”
Laravel SwiftMailer : Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required
我正在使用 laravel 5.2,并使用 Swift 邮件程序进行密码重置。
我的 Gmail 有两步验证。。
正如 google 帮助所说:
如果您已为您的帐户启用两步验证,您可能需要输入应用密码而不是常规密码。
我在 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
"
使用 tls 而不是 ssl 并使用端口 587。
使用密钥或密码。
或者请 运行 php artisan config:cache
或者尝试在此页面上启用您的帐户 "less secure apps"。
尝试在 this page. Read this google answer 上启用您帐户的 "less secure apps"。
关注这个文件......
将"Username" => env('your-gmail-account@gmail.com')更改为"Username" => 'your-gmail-account@gmail.com';
与密码相同...
return[
/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill",
| "ses", "sparkpost", "log"
|
*/
'driver' => env('MAIL_DRIVER', 'smtp'),
/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/
'port' => env('MAIL_PORT', 587),
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => ['address' => 'only5test@gmail.com', 'name' => 'shashikant parmar111'],
/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/
**'username' => 'Your-gmail-account@gmail.com',**
/*
|--------------------------------------------------------------------------
| SMTP Server Password
|--------------------------------------------------------------------------
|
| Here you may set the password required by your SMTP server to send out
| messages from your application. This will be given to the server on
| connection so that the application will be able to send messages.
|
*/
**'password' => '********',**
/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => FALSE,
];
您可以尝试以下步骤
- 为您的帐户 here 启用 "less secure apps"。
- 尝试在
.env
文件
中将邮件加密设置为 tls
并将端口设置为 587
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-password
MAIL_ENCRYPTION=tls
- 然后运行
php artisan cache:clear
这对我来说效果很好。
在 laravel 中,我也遇到了同样的问题,但这是因为...我没有在邮件功能中使用 "use clause"。
使用"use clause"后错误得到解决。
伙计,输入 google 设置、安全选项、安全警报。那里你可能有 google 块的警报......你的代码很好,只有 google 正在阻止你,给它许可并准备好......
enter image description here
我正在使用 laravel 5.2,并使用 Swift 邮件程序进行密码重置。 我的 Gmail 有两步验证。。
正如 google 帮助所说:
如果您已为您的帐户启用两步验证,您可能需要输入应用密码而不是常规密码。
我在 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
"
使用 tls 而不是 ssl 并使用端口 587。
使用密钥或密码。
或者请 运行 php artisan config:cache
或者尝试在此页面上启用您的帐户 "less secure apps"。
尝试在 this page. Read this google answer 上启用您帐户的 "less secure apps"。
关注这个文件......
将"Username" => env('your-gmail-account@gmail.com')更改为"Username" => 'your-gmail-account@gmail.com';
与密码相同...
return[
/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill",
| "ses", "sparkpost", "log"
|
*/
'driver' => env('MAIL_DRIVER', 'smtp'),
/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/
'port' => env('MAIL_PORT', 587),
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => ['address' => 'only5test@gmail.com', 'name' => 'shashikant parmar111'],
/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/
**'username' => 'Your-gmail-account@gmail.com',**
/*
|--------------------------------------------------------------------------
| SMTP Server Password
|--------------------------------------------------------------------------
|
| Here you may set the password required by your SMTP server to send out
| messages from your application. This will be given to the server on
| connection so that the application will be able to send messages.
|
*/
**'password' => '********',**
/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => FALSE,
];
您可以尝试以下步骤
- 为您的帐户 here 启用 "less secure apps"。
- 尝试在
.env
文件
中将邮件加密设置为tls
并将端口设置为587
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-password
MAIL_ENCRYPTION=tls - 然后运行 php artisan cache:clear
这对我来说效果很好。
在 laravel 中,我也遇到了同样的问题,但这是因为...我没有在邮件功能中使用 "use clause"。
使用"use clause"后错误得到解决。
伙计,输入 google 设置、安全选项、安全警报。那里你可能有 google 块的警报......你的代码很好,只有 google 正在阻止你,给它许可并准备好...... enter image description here