预期响应代码 250,但收到代码"530",消息"530 5.7.0 必须先发出 STARTTLS 命令。g17sm239505vkg.44 - gsmtp "



这是我第一次尝试在Laravel中使用恢复密码功能,但我遇到了麻烦。把代码放到env文件和mail。php文件

中环境文件代码

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=MyEmail@gmail.com
MAIL_PASSWORD=################ (gmail code when setting up custom less secure app)
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=MyEmail@gmail.com
MAIL_FROM_NAME="${APP_NAME}"

Mail.php代码

<?php
return [
'default' => env('MAIL_MAILER', 'smtp'),
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => '/usr/sbin/sendmail -bs',
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
],

'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME','hospitalnuestrocorazon@gmail.com'),
'password' => env('MAIL_PASSWORD','################'),
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];

我已经尝试解决这个问题,但没有成功。

在修改env文件后用php artisan config: cache刷新缓存

您正在使用587端口,但在您的环境中有

MAIL_PORT=587
MAIL_ENCRYPTION=null

对于laravel,我建议尝试使用tls作为您的MAIL_ENCRYPTION参数。这将导致

MAIL_PORT=587
MAIL_ENCRYPTION=tls

相关内容

  • 没有找到相关文章

最新更新