Laravel 5.5 预期响应代码 250 但得到代码“530”

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

Laravel 5.5 Expected response code 250 but got code "530"

laravellaravel-5

提问by Niladri Banerjee - Uttarpara

I know it is a duplicate issue in StackOverFlow (Laravel SwiftMailer : Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required) however, I'm done all the remedies discussed there but still no luck. I'm using mailtrap.io using my GMail account. Here is the .env file and mail.php (under config):

我知道这是 StackOverFlow 中的一个重复问题(Laravel SwiftMailer:预期响应代码 250 但得到代码“530”,消息为“530-5.5.1 Authentication Required”)但是,我已经完成了那里讨论的所有补救措施,但仍然没有运气. 我正在使用我的 GMail 帐户使用 mailtrap.io。这是 .env 文件和 mail.php(在配置下):

.env

.env

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

mail.php

邮件.php

'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailtrap.io'),
'port' => env('MAIL_PORT', 2525),
'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'Niladri Banerjee'),
    ],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'sendmail' => '/usr/sbin/sendmail -t -i',
'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

After submitting the valid email from forgot password screen, it throws the following error:

从忘记密码屏幕提交有效电子邮件后,它会引发以下错误:

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

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

Please note: I have already ON 'Allow less secure apps' from "Sign-in & security" from my GMail.

请注意:我已经在 GMail 的“登录和安全”中启用了“允许安全性较低的应用”。

Seeking your help.

寻求你的帮助。

PS: I'm running the project in localhost.

PS:我在本地主机上运行该项目。

回答by Ndong Akwo

I' may suggest you use this as well, it worked for me,

我可能建议你也用这个,它对我有用

Please Note if you're using Gmail: create a gmail app password, but be sure to your 2 Step verification set up, from sign in and securiity, the following link: https://myaccount.google.com/apppasswordsto setup app password, use that and follow procedure 2 after this return to set up gmail with smtp.

请注意,如果您使用 Gmail:创建 Gmail 应用程序密码,但请确保您的 2 步验证设置,从登录和安全,以下链接:https://myaccount.google.com/apppasswords到设置应用程序密码,使用该密码并在返回后按照步骤 2 设置带有 smtp 的 gmail。

please note: code down below are for mail.php file

请注意:下面的代码用于 mail.php 文件

(do not forget to use: php artisan config:cache) after changes to .env file as well

(不要忘记使用:php artisan config:cache)更改 .env 文件后

return [

'driver' => env('MAIL_DRIVER', 'smtp'),

'host' => env('MAIL_HOST', 'smtp.mailtrap.io'),

'port' => env('MAIL_PORT', 2525),

'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'myMail'),
    ],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),

'username' => env('MAIL_USERNAME'),//this setting in .env only leave as is here

'password' => env('MAIL_PASSWORD'),//this setting in .env only leave as is here

'sendmail' => '/usr/sbin/sendmail -bs',

'stream' => [
    'ssl' => [
        'allow_self_signed' => true,
        'verify_peer' => false,
        'verify_peer_name' => false,
    ],
    ],

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],
];

//procedure 2 for gmail return [

//gmail返回的过程2 [

'driver' => env('MAIL_DRIVER', 'smtp'),

'host' => env('MAIL_HOST', 'smtp.gmail.com'),

'port' => env('MAIL_PORT', 587),

'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'myMail'),
    ],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),

'username' => env('MAIL_USERNAME'),//this setting in .env only leave as is here

'password' => env('MAIL_PASSWORD'),//this setting in .env only (use app password you created for gmail and PLEASE leave as is here

'sendmail' => '/usr/sbin/sendmail -bs',

'stream' => [
    'ssl' => [
        'allow_self_signed' => true,
        'verify_peer' => false,
        'verify_peer_name' => false,
    ],
    ],

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],
];

Hope it helps. Kind regards

希望能帮助到你。亲切的问候