正在尝试通过Laravel发送电子邮件。
但是它正在出错。
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemailID@gmail.com
MAIL_PASSWORD=******
MAIL_ENCRYPTION=tls
$data = array('name'=>"Ripon Uddin", "body" => "Test mail");
Mail::send('email', $data, function($message) {
$message->to('ToEmailID@yahoo.com','To My Yahoo')->subject('Laravel Test Email');
$message->from('ToFromID@gmail.com','Ripon Uddin (Laravel Lover)');
});
错误信息:
无法使用3个可能的验证器在用户名“ myEmailID@gmail.com”的SMTP服务器上进行验证。身份验证器LOGIN返回Swift_TransportException:预期的响应代码为235,但代码为“ 535”,消息为“ 535-5.7.8,用户名和密码未接受。有关更多信息,请参见535 5.7.8 https://support.google.com/mail/?p=BadCredentials r18-v6sm7406256pgv.17-gsmtp“在
答案 0 :(得分:2)
您不需要GSuite来执行此操作...我已经与Laravel&GMail进行了很多次此集成。只需转到您的Google帐户>安全>不太安全的应用访问权限,然后单击“打开访问权限(不建议使用)” See image for more info
答案 1 :(得分:2)
转到此link或gmail的应用程序密码页面,然后选择“邮件”作为“应用程序”,并选择客户名称作为“设备”。然后,您将获得应用密码。
只需在生产模式下的生产文件夹或环境文件中转到config文件夹下的laravel mai.php。将生成的代码粘贴到密码部分'password' => 'generated code',
上
毕竟运行:php artisan config:cache
答案 2 :(得分:0)
如果您在gmail设置中启用了“允许安全性较低的应用”设置,则此配置适用于 Gmail :
mailer_transport: smtp
mailer_host: smtp.gmail.com
mailer_port: 465
mailer_encryption: ssl
mailer_auth_mode: login
mailer_user: xxxx@xxxxxxx.com
mailer_password: "xxxx"
如果您在gmail设置中将服务器的IP列入白名单,则此服务器将在 Gmail Suite 上运行(请参见https://support.google.com/a/answer/2956491)
mailer_transport: smtp
mailer_host: smtp-relay.gmail.com
mailer_port: 587
mailer_encryption: tls
mailer_auth_mode: login
mailer_user: xxx@xxxxxxx.com
mailer_password: "xxxx"
答案 3 :(得分:0)
确保您的用户凭据在 .env 文件中正确。
<块引用>尝试将您的密码放在引号中。例如:MAIL_PASSWORD="mypassword"
应用更改运行
<块引用>php 工匠配置:缓存
答案 4 :(得分:0)
您是否开启了“允许安全性较低的应用”?转到此链接
https://myaccount.google.com/security#connectedapps
查看登录和安全 -> 具有帐户访问权限的应用菜单。
您必须开启“允许安全性较低的应用”选项。