php 预期响应代码 250,但得到代码“535”,消息为“535-5.7.8 用户名和密码不被接受

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42558903/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:38:02  来源:igfitidea点击:

Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted

phplaravelgmail

提问by Camilo Go Jr.

I recently encountered a SwiftMail error while trying to send a mail through gmail.

我最近在尝试通过 gmail 发送邮件时遇到了 SwiftMail 错误。

 Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted.

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.

我试图通过我的 gmail 发送邮件,谷歌认为我是垃圾邮件(可能是因为我请求太快了)我收到了一封来自他们的邮件,说我的帐户可以访问,我告诉他们是我。我能够毫无问题地发送邮件,现在才发生。

This is the contents of my env file.

这是我的 env 文件的内容。

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=mypasswordhere
[email protected]
MAIL_NAME=talentscout

回答by Camilo Go Jr.

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.

我在互联网上进行了研究,一些答案包括启用“访问较小的应用程序”和“解锁 gmail 验证码”,遗憾的是,在我找到两步验证之前,这对我不起作用。

What I did the following was:

我所做的是:

  1. enable the 2-step verificationto google HERE

  2. Create App Password to be use by your system HERE

  3. I selected Others (custom name)and clicked generate

  4. Went to my env file in laravel and edited this

    [email protected]

    MAIL_PASSWORD=thepasswordgenerated

  5. Restarted my apache server and boom! It works again.
  1. 启用两步验证到谷歌这里

  2. 此处创建供系统使用的应用密码

  3. 我选择了其他(自定义名称)并单击生成

  4. 转到我在 laravel 中的 env 文件并对其进行了编辑

    [email protected]

    MAIL_PASSWORD=生成的密码

  5. 重新启动我的 apache 服务器并繁荣!它再次起作用

This was my solution. I created this to atleast make other people not go wasting their time researching for a possible answer.

这是我的解决方案。我创建它是为了至少让其他人不会浪费时间研究可能的答案。

回答by M-O-H-S-E-N

I had the same problem, changing my gmail password fixed the issue, and also don't forget to enable less secure app on on your gmail account

我遇到了同样的问题,更改我的 Gmail 密码解决了该问题,并且不要忘记在您的 Gmail 帐户上启用安全性较低的应用程序

回答by Tigran

i had same issue i resolve this use under

我有同样的问题我解决了这个使用

go to gmail.com

去 gmail.com

my account

我的账户

and enable

并启用

Allow less secure apps: ON

允许不太安全的应用程序:开

it start works

它开始工作

回答by Masiur Rahman Siddiki

I had everything fine. Less secure app option was also enabled. Still, I was getting the error. What I have done is:

我一切都很好。还启用了不太安全的应用程序选项。尽管如此,我还是收到了错误。我所做的是:

  • Google will send you Critical security alert
  • Then you have to authorize that activity. ( Clicking on 'YES, THAT WAS ME' type thing )
  • Then you can try sending email again.
  • Google 会向您发送严重安全警报
  • 然后您必须授权该活动。(点击“是的,那是我”类型的东西)
  • 然后您可以尝试再次发送电子邮件。

回答by ovie tennyson

This is my .env mail settings

这是我的 .env 邮件设置

MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=hello27
MAIL_ENCRYPTION=tls

i was getting thesame error as stated in the question but by using

我遇到了与问题中所述相同的错误,但通过使用

php artisan config:cache

Everything worked fine

一切正常

回答by zeetit

This single step worked for me... No 2-step verification. As I had created a dummy account for my local development, so I was OK with this setting. Make sure you only do this if your account contains NO personal or any critical data. This is just another way of tackling this error and NOT secure.

这一步对我有用......没有两步验证。由于我为我的本地开发创建了一个虚拟帐户,所以我对这个设置没问题。请确保仅在您的帐户不包含个人数据或任何关键数据时才执行此操作。这只是解决此错误的另一种方法,并不安全。

I turned ON the setting to alow less secured apps to be allowed access. Form here : https://myaccount.google.com/lesssecureapps

我打开设置以允许访问安全性较低的应用程序。在这里形成:https: //myaccount.google.com/lesssecureapps

回答by Jiwan

Gmail tends to block usage of mailing addresses which are being used in other applications as username for security reasons. Either you should create a new email address for mail purpose or you must go to the Less Secure App Access and turn on the access for less secure apps. Gmail will send you a mail for confirmation from where you can verify that those changes were made by yourself. Only then, you can use such mailing addresses for mailing purpose through applications.

出于安全原因,Gmail 倾向于阻止在其他应用程序中用作用户名的邮寄地址。您应该为邮件目的创建一个新的电子邮件地址,或者您必须转到“不太安全的应用程序访问”并打开对不太安全的应用程序的访问。Gmail 会向您发送一封确认邮件,您可以从中验证这些更改是否由您自己完成。只有这样,您才能通过应用程序将此类邮寄地址用于邮寄目的。

回答by sachinsuthariya

There is no need to update anything in config/mail.php. just put you credential in .envwith this specific key's. This is my .envfile.

不需要更新config/mail.php 中的任何内容。只需使用此特定密钥将您的凭据放入.env 中。这是我的.env文件。

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=********
MAIL_ENCRYPTION=tls

I had the same issue after long time debugging and googling i have found the solution. that by enabling less secure apps. the email started working.

经过长时间的调试和谷歌搜索后,我遇到了同样的问题,我找到了解决方案。通过启用不太安全的应用程序。电子邮件开始工作。

if your gmail is secure with 2 step verification you can't enable less secure app. so turn off 2 step verification and enable less secure app. by click here enable less secure apps on your gmail account

如果您的 Gmail 通过两步验证是安全的,您将无法启用安全性较低的应用。所以关闭两步验证并启用安全性较低的应用程序。通过单击此处在您的 Gmail 帐户上启用安全性较低的应用程序

回答by Daniel Beltrami

I had the same problem, then I did this two steps:

我遇到了同样的问题,然后我做了这两个步骤:

  • Enable "Allow less secure apps" on your google account security policy.
  • Restart your local servers.
  • 在您的 Google 帐户安全策略中启用“允许安全性较低的应用程序”。
  • 重新启动本地服务器。