jeudi 24 décembre 2015

Try to send mail with Laravel 5.0 but got error "Expected response code 220 but got code "", with message """ [duplicate]

This question already has an answer here:

I'm working with Laravel 5.0 and I would like to send mail in my Controller. For the moment I'm testing with this code :

Controller

Mail::send('emails.test', ['key' => 'value'], function($message)
    {
        $message->to('adress@gmail.com', 'Name')->subject('Test!');
    });

And I have a simple view but it's not the problem. The problem is I got an error when sending the mail :

Expected response code 220 but got code "", with message ""

I don't understand why it doesn't work, I test with a dedicated mail server and with gmail (see configuration below)

.env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myadress@gmail.com
MAIL_PASSWORD=mypassword

mail.php

return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'adress@gmail.com', 'name' => 'Name'],
'encryption' => 'ssl',
'username' => env('USERNAME'),
'password' => env('PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];

I already search on Internet the solutions but none of them are working. My application is run on WAMP (localhost)

Thanks in advance :)

EDIT : With gmail, I activated two step verification, I also used : php artisan config:cache and php artisan config:clear



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire