Laravel Mailtrap Localhost - 发送邮件时出错

时间:2017-05-13 22:02:11

标签: laravel email

我希望在处理gmail时使用Laravel 5.4Mailtraplocalhost:8888地址发送电子邮件。

我收到此错误Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required

我试过

  • 使用不同的端口
  • php artisan config:clear

有什么问题?

.ENV

 MAIL_DRIVER=smtp
    MAIL_HOST=mailtrap.io
    MAIL_PORT=465
    MAIL_USERNAME=xxxxx
    MAIL_PASSWORD=xxxxx
    MAIL_ENCRYPTION=null
    MAIL_FROM_ADDRESS=example@example.com
    MAIL_FROM_NAME=Leo

配置/ mail.php

 'driver' => env('MAIL_DRIVER', 'smtp'),
  'host' => env('MAIL_HOST', 'smtp.mailtrap.io'),
  'from' => [
    'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
    'name' => env('MAIL_FROM_NAME', 'Example'),
  ],
  'username' => env('xxxxx'),
  'password' => env('xxxxx'),

2 个答案:

答案 0 :(得分:2)

我需要改变

'username' => env('xxxxx'),
'password' => env('xxxxx'),

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

答案 1 :(得分:0)

The below code (in .env file) solved my problem in sending verification 
email - Laravel 5.7. No need to change in config/mail.php

MAIL_DRIVER=smtp
MAIL_HOST=mail.somedomain.org
MAIL_PORT=465
MAIL_USERNAME=someone@somedomain.org
MAIL_PASSWORD=your_pwd
MAIL_ENCRYPTION=SSL
MAIL_FROM_ADDRESS=someone@somedomain.org
MAIL_FROM_NAME=SenderName