[英]Configuring Emails in Laravel
I am trying to setup emails in my Laravel aplication, I have my env file something like this:我正在尝试在我的 Laravel 应用程序中设置电子邮件,我的环境文件如下所示:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=noreply@xxx.com
MAIL_PASSWORD=xxx
MAIL_ENCRYPTION=tls
I tried according to the answer given in this question Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted我根据这个问题中给出的答案进行了尝试Expected response code 250 但得到代码“535”,消息“535-5.7.8 Username and Password not accepted
I followed the steps, enabled 2 step verification, then created app password and configured my .env
file我按照步骤操作,启用了两步验证,然后创建了应用密码并配置了我的
.env
文件
Finally I did php artisan config:cache
最后我做了
php artisan config:cache
Failed to authenticate on SMTP server with username "noreply@xxx.com" using 3 possible authenticators.
无法使用 3 个可能的身份验证器在用户名为“noreply@xxx.com”的 SMTP 服务器上进行身份验证。 Authenticator LOGIN returned Swift_TransportException: Expected response code 235 but got code "534", with message "534-5.7.14
身份验证器登录返回 Swift_TransportException:预期响应代码 235 但得到代码“534”,消息“534-5.7.14
Please help me out with this.这个你能帮我吗。 Thanks.
谢谢。
Need to create new
less secure
gmail account for configuration需要创建新的
less secure
Gmail 帐户来配置not use in more than 3 projects
.您的电子邮件不应
not use in more than 3 projects
。
I had the same problem.我有同样的问题。 It was the Captcha link that fixed the issue, even though I don't use it.
即使我不使用它,也是解决问题的验证码链接。 It seems there is an additional step to allow new devices to open the gmail account.
似乎还有一个额外的步骤来允许新设备打开 gmail 帐户。
https://support.google.com/mail/answer/7126229?visit_id=636865986363810933-1186759849&rd=1#cantsignin https://support.google.com/mail/answer/7126229?visit_id=636865986363810933-1186759849&rd=1#cantsignin
I had already set up this below beforehand我事先已经在下面设置了这个
Allow less secure apps: If you don't use 2-Step Verification, you might need to allow less secure apps to access your account.允许安全性较低的应用:如果您不使用两步验证,则可能需要允许安全性较低的应用访问您的帐户。
如果以上所有答案都无法解决,请转到您的帐户设置https://myaccount.google.com/security打开两步验证并生成应用程序密码,这种方式肯定有效。
Steps to configure Gmail/Google SMTP with Laravel使用 Laravel 配置 Gmail/Google SMTP 的步骤
.env
file setup .env
文件设置
MAIL_DRIVER=smtp MAIL_HOST=smtp.googlemail.com MAIL_PORT=465 MAIL_USERNAME=GMAIL_USERNAME MAIL_PASSWORD=GMAIL_PASSWORD MAIL_ENCRYPTION=ssl
Allow Less Secure Apps允许不太安全的应用程序
Go to Google Accounts > Security > Allow less secure apps.
转到 Google 帐户 > 安全 > 允许不太安全的应用。
https://www.google.com/accounts/DisplayUnlockCaptcha
https://www.google.com/accounts/DisplayUnlockCaptcha
PS - If you have 2 step verification enabled, then Create app password and use that instead of GMAIL_PASSWORD
PS - 如果您启用了两步验证,则创建应用密码并使用该密码而不是
GMAIL_PASSWORD
Reference - https://support.google.com/mail/answer/7126229参考 - https://support.google.com/mail/answer/7126229
You can use MAIL_PASSWORD=yourapppassword instead of gmail password like您可以使用MAIL_PASSWORD=yourapppassword代替 gmail 密码,例如
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=GMAIL_USERNAME
MAIL_PASSWORD=APP_PASSWORD
MAIL_ENCRYPTION=ssl
If u are not created.如果你没有被创造。 Create a new one go to Google Account ,then security then u will app password.
创建一个新的去谷歌帐户,然后安全然后你将应用密码。
use app password instead of gmail password go to gmail settings/security In Signing in to Google section open app password and generate password使用应用程序密码而不是 gmail 密码 go 到 gmail 设置/安全 在登录到 Google 部分打开应用程序密码并生成密码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.