AbstractSmtpTransport.php第383行中的Swift_TransportException:在Laravel中

时间:2017-05-24 06:08:57

标签: laravel laravel-5

我正在尝试使用laravel 5.4创建一个联系表单,我将我的服务器电子邮件详细信息添加到.env和mail.php但我收到此错误

  

AbstractSmtpTransport.php第383行中的Swift_TransportException:   预期的响应代码250,但得到代码“421”,消息“421意外失败,请稍后再试   “

如果我尝试这个并使用mailtrap它可以正常工作。

这是我的mail.php

return [

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

    'host' => env('MAIL_HOST', 'smtp.mailgun.org'),

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

    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'info@website.co.za'),
        'name' => env('MAIL_FROM_NAME', 'Info'),
    ],

    'encryption' => env('MAIL_ENCRYPTION', 'tls'),

    'username' => env('MAIL_USERNAME'),

    'password' => env('MAIL_PASSWORD'),

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

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

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

];

我的.env文件

MAIL_DRIVER=smtp
MAIL_HOST=hosting.com
MAIL_PORT=587
MAIL_USERNAME=info@website.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=

1 个答案:

答案 0 :(得分:0)

检查config / mail.php

return [
    'driver' => env('MAIL_DRIVER', 'smtp'),
    'host' => env('MAIL_HOST', ''),
    'port' => env('MAIL_PORT', 587),
    'from' => ['address' => null, 'name' => null],
    'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    'username' => env('MAIL_USERNAME', ''),
    'password' => env('MAIL_PASSWORD', ''),
    'sendmail' => '/usr/sbin/sendmail -bs',
];

确保.env文件具有以下内容

MAIL_DRIVER=smtp
MAIL_HOST=hosting website 
MAIL_PORT=587
MAIL_USERNAME=your username
MAIL_PASSWORD=your password
MAIL_ENCRYPTION=tls

同时清除配置缓存

php artisan config:cache