Léo Coco
Léo Coco

Reputation: 4282

Laravel Mailtrap Localhost - Error sending mail

I would like to send a emai to a gmail address using Laravel 5.4 and Mailtrap while working on my localhost:8888.

I've got this error Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required

I tried

What is wrong ?

.env

 MAIL_DRIVER=smtp
    MAIL_HOST=mailtrap.io
    MAIL_PORT=465
    MAIL_USERNAME=xxxxx
    MAIL_PASSWORD=xxxxx
    MAIL_ENCRYPTION=null
    [email protected]
    MAIL_FROM_NAME=Leo

config/mail.php

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

Upvotes: 1

Views: 3898

Answers (2)

PS324
PS324

Reputation: 11

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
[email protected]
MAIL_PASSWORD=your_pwd
MAIL_ENCRYPTION=SSL
[email protected]
MAIL_FROM_NAME=SenderName

Upvotes: 0

Léo Coco
Léo Coco

Reputation: 4282

I needed to change

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

to

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

Upvotes: 2

Related Questions