Send mail with Laravel

- 1 answer

Ad

I try to send a mail with Laravel, but it doesn't work. I've tried with Mandrill, mailgun and with gmail. Mandrill returns message like "missing SPF and DKIM".

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME="my gmail adress"
MAIL_PASSWORD="my gmail password"
MAIL_ENCRYPTION=tls
MAIL_PRETEND=true

That is in my EmailController :

Mail::send('emails.welcome', ['name' => 'Novice'], function($message){
    $message->to('f***@gmail.com', 'Fabien')->subject('Bienvenue !');
});

That is the route :

Route::resource('emails', 'EmailController');

How can I fix it ?

Ad

Answer

Ad

Change MAIL_PRETEND to false. This option is used to test sending mails without sending.

Also, since Laravel 5.2 the option pretend won't exists anymore.

The pretend mail configuration option has been removed. Instead, use the log mail driver, which performs the same function as pretend and logs even more information about the mail message.

Read more: Upgrading to 5.2, Mail & Local Development

Ad
source: stackoverflow.com
Ad