Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mail::queue() and Mail::later() don't use currently set SMTP config #4260

Closed
fisle opened this issue Apr 28, 2014 · 2 comments
Closed

Mail::queue() and Mail::later() don't use currently set SMTP config #4260

fisle opened this issue Apr 28, 2014 · 2 comments

Comments

@fisle
Copy link

fisle commented Apr 28, 2014

I set SMTP server on-the-fly with:

$config = array(
    'driver' => 'smtp',
    'host' => 'smtp.host.com',
    'port' => 587,
    'from' => array('address' => '[email protected]', 'name' => 'name'),
    'encryption' => 'tls',
    'username' => 'my_username',
    'password' => 'my_pass',
    'sendmail' => '/usr/sbin/sendmail -bs',
    'pretend' => false
);
Config::set('mail', $config);

Now when I send mail with Mail::send(), it works just fine and uses the server I set.
But when using Mail::queue() or Mail::later(), it instead tries to use the default SMTP settings from app/config/mail.php.

Is there a workaround this? I took a look in src/Illuminate/Mail/Message.php but there was no function to attach SMTP info into the Mail::queue() call which would have worked in this situation.

@GrahamCampbell
Copy link
Member

Don't set config on demand is the sollution. Otherwise, your solution would be to create a custom mailer instance, serialize it, and send it with your own custom queue job, or probably, more reliably, pass the config with your own custom queue job, then create a mailer at the other end from the config.

@taylorotwell
Copy link
Member

The config won't persist past the current request. Alternatively use Queue::push and use a custom job that calls Mail::send and set the config in THAT job.

taylorotwell pushed a commit that referenced this issue May 10, 2017
If PR laravel/laravel#4260 is accepted we will no longer need window.Laravel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants