Laravel 5.5预期响应代码250,但得到代码" 530"

时间:2018-05-29 10:23:54

标签: laravel laravel-5

我知道这是StackOverFlow中的一个重复问题(Laravel SwiftMailer : Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required)但是,我已经完成了所讨论的所有补救措施,但仍然没有运气。我使用我的GMail帐户使用mailtrap.io。这是.env文件和mail.php(在config下):

.ENV

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

mail.php

'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailtrap.io'),
'port' => env('MAIL_PORT', 2525),
'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'niladriXXX@XXX.com'),
        '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'),
        ],
    ],

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

  

预期的响应代码250,但得到了代码" 530",带有消息" 530 5.7.1需要认证"

请注意:我已经开启'允许不太安全的应用程序'来自"登录&安全"来自我的GMail。

寻求帮助。

PS:我在localhost中运行项目。

1 个答案:

答案 0 :(得分:5)

我'可能建议你也使用它,它对我有用,

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

请注意:以下代码适用于mail.php文件

(别忘了使用: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', 'lxxxx@xxxx.com'),
        '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'),
        ],
    ],
];

//针对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', 'lxxxx@gmail.com'),
        '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'),
        ],
    ],
];

希望它有所帮助。 亲切的问候