Framework: Mail::pretend() doesn't work for queued mail

Created on 6 Jun 2013  路  4Comments  路  Source: laravel/framework

When using queuing email (queue driver=sync, mail driver=mail), the $pretend flag previously set is not being picked up. When the job fires, it creates a new 'mailer' object, losing the old value.

Makes it kinda hard to test without some fudging.

Maybe 'pretend' should be a config parameter? Then can be handled in MailServiceProvider::register()

Most helpful comment

Nevermind, solved it.

For future reference: if you have queues running in the background (via supervisor, for example), you need to restart them for it to pick up new changes.

All 4 comments

+1 for a config param

This has been moved to config.

Sorry if I open this again, I'm still having this issue.
I'm using Laravel 5.1.

in my config/mail:
'pretend' => env('MAIL_PRETEND', true),

in my .env file:
MAIL_PRETEND=true

Using Mail::send() correctly pretends to send it and writes it on the log file.
Using Mail::queue() actually sends the email (I accidentally emailed people from my dev environment)

Queue is set to use the database driver.
Listening to queue with a supervisor worker:
php /var/www/myproject/artisan queue:listen database

Using Mandrill as the email driver.

Nevermind, solved it.

For future reference: if you have queues running in the background (via supervisor, for example), you need to restart them for it to pick up new changes.

Was this page helpful?
0 / 5 - 0 ratings