php 预期响应代码 250,但得到代码“530”,消息为“530 5.7.1 需要身份验证”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48341078/
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:39:55  来源:igfitidea点击:

Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required

phplaravellaravel-5

提问by Abdallah Abdillah

I got stuck on this error I trying to configure SMTP mail on laravel

我在尝试配置 SMTP 邮件时遇到了这个错误 laravel

here is the error

这是错误

here is my configuration on .env

这是我的配置 .env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=fff3c01db52ee0
MAIL_PASSWORD=feaeda91dc9ab6
MAIL_ENCRYPTION=TLS

here is  my mail.php on config

这是我的 mail.php 配置文件

I have to try to authenticate the SMTP on env but I keep getting the same error so for now am stack on that error

我必须尝试在 env 上对 SMTP 进行身份验证,但我一直收到相同的错误,所以现在我在该错误上堆栈

回答by Abdallah Abdillah

your mail.phpon config you declare host as smtp.mailgun.organd port is 587while on env is different. you need to change your mail.phpto

mail.php在配置上声明主机为smtp.mailgun.org和端口是,587而在 env 上是不同的。你需要改变你mail.php

'host' => env('MAIL_HOST', 'mailtrap.io'),
'port' => env('MAIL_PORT', 2525),

if you desire to use mailtrap.Then run

如果你想使用mailtrap.然后运行

php artisan config:cache

回答by DAVID AJAYI

I believe this has been answered in some sections already, just test with gmail for your "MAIL_HOST" instead and don't forget to clear cache. Setup like below: Firstly, you need to setup 2 step verification here google security. An App Password link will appear and you can get your App Password to insert into below "MAIL_PASSWORD". More info on getting App Password here

我相信这已经在某些部分得到了回答,只需使用 gmail 测试您的“MAIL_HOST”,不要忘记清除缓存。设置如下:首先,您需要在google security 中设置两步验证。将出现一个应用密码链接,您可以将您的应用密码插入到“MAIL_PASSWORD”下方。有关在此处获取应用密码的更多信息

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

Clear cache with:

清除缓存:

php artisan config:cache

回答by Software Developer

That is basically authentication error due to misconfiguration of email settings.

这基本上是由于电子邮件设置配置错误导致的身份验证错误。

Go to .envfile

转到.env文件

change

改变

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

to

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com    
MAIL_PORT=465    
MAIL_USERNAME=ENTER_YOUR_EMAIL_ADDRESS(GMAIL)    
MAIL_PASSWORD=ENTER_YOUR_GMAIL_PASSWORD    
MAIL_ENCRYPTION=ssl

The MAIL_USERNAME and PASSWORD should be replaced with your Gmail Email address and Password respectively. Login to your Google Account, Go to security settings and enable Allow Less Secure Appswitch button.

MAIL_USERNAME 和 PASSWORD 应分别替换为您的 Gmail 电子邮件地址和密码。登录您的 Google 帐户,转到安全设置并启用“允许不太安全的应用”开关按钮。

After that go to your project root directory and run the following command:

之后转到您的项目根目录并运行以下命令:

php artisan clear:cache && php artisan clear:config && php artisan config:cache

. Please refer to

. 请参阅

this guide for assistance and clarification (Note: For MAIL_HOSTuse smtp.gmail.com)

本指南以获得帮助和说明(注意:对于MAIL_HOST,请使用 smtp.gmail.com)

回答by Gjaa

I see you have all the settings right. You just need to end the local web server and start it again with

我看到你有所有的设置。您只需要结束本地 Web 服务器并重新启动它

php artisan serve

Everytime you change your .envfile, you need tor restart the server for the new options to take effect.

每次更改.env文件时,都需要重新启动服务器以使新选项生效。

Or clear and cache your configuration with

或清除并缓存您的配置

php artisan config:cache

回答by Gilberto Albino

Yep, and if you have tried all the above solutions (what's more likely to happen) and none work for you, it may happen that Guzzle is not installed.

是的,如果您已经尝试了上述所有解决方案(更有可能发生的情况)但都不适合您,则可能是因为没有安装 Guzzle。

Laravel ships mailing tools, by which is required the Guzzle framework, but it won't be installed, and AS OF the documentation, will have to install it manually: https://laravel.com/docs/master/mail#driver-prerequisites

Laravel 提供邮件工具,Guzzle 框架需要使用该工具,但不会安装,并且根据文档,必须手动安装:https: //laravel.com/docs/master/mail#driver-先决条件

composer require guzzlehttp/guzzle