1

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 ?

2

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

5 Comments

Hi, I tried with false value and without MAIL_PREVEND var but nothing happened.
@Swarovski Look in config/mail.php for pretend key and see what value is there, old Laravel could have false or true without integration with .env file.
@Svarowski In directory storage/logs you should have logs files. Try to send an e-mail and then see in *.log file what appered there. Also try to set debug to true value and check return value of sending mails ($mail = Mail::send(...); var_dump($mail);) and check what is a response. By default, SwiftMailer return number of recipients who were accepted for delivery (swiftmailer/lib/classes/Swift/Mailer.php:74-92).
When I dump $mail I get this message "int 1". Debug is on true and nothing new in .log file
@Swarovski maybe try to change port to MAIL_PORT=465 and encryption to MAIL_ENCRYPTION=ssl. Also you could read more about Gmail configuration: support.google.com/a/answer/176600?hl=en . The problem is not your code but your settings or your server or your Gmail account. SwiftMailer tells you that you send one e-mail to one recipient so in PHP everything works good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.