问题描述
我最近在尝试通过gmail发送邮件时遇到了SwiftMail错误.
I recently encountered a SwiftMail error while trying to send a mail through gmail.
Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted.
我试图通过gmail发送邮件,而google认为我是垃圾邮件(也许是因为我请求的速度太快了).我收到了他们的来信,说我的帐户可以访问,我告诉他们是我.我能够毫无问题地发送邮件,而这只是现在发生了.
I was trying to send mail through my gmail and google thought that I was a spam(maybe because I was requesting too fast) I received a mail from them saying my account was access and I told them it was me. I was able to send mail without problem and it just occured now.
这是我的环境文件的内容.
This is the contents of my env file.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=mypasswordhere
[email protected]
MAIL_NAME=talentscout
推荐答案
我在互联网上进行了研究,一些答案包括启用"访问较小应用程序"和"解锁gmail验证码",但不幸的是,直到我找到两步验证后,它才对我有用.
I researched on the internet and some answers includes enabling the "access for lesser app" and "unlocking gmail captcha" which sadly didn't work for me until I found the 2-step verification.
我做了以下事情:
-
启用两步验证到Google HERE
创建要由系统使用的应用密码此处
Create App Password to be use by your system HERE
我选择了其他(自定义名称),然后单击了生成
I selected Others (custom name) and clicked generate
在laravel中进入我的环境文件并对其进行了编辑
Went to my env file in laravel and edited this
MAIL_PASSWORD =生成的密码
MAIL_PASSWORD=thepasswordgenerated
这是我的解决方案.我创建这个标签的目的是至少使其他人不要浪费时间研究可能的答案.
This was my solution. I created this to atleast make other people not go wasting their time researching for a possible answer.
这篇关于预期的响应代码为250,但代码为"535",消息为"535-5.7.8",用户名和密码不被接受的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!