Support the ongoing development of →
Configuration Mail Architecture
Last updated 1 year ago.

Have you tried to update config array on the fly?

Last updated 1 year ago.

You could update mail.php with something like:

'host' => Config::get(''),
'user' => Config::get('mail.sender.user'),


If you need to update the config values at runtime you can do it with:

Config::set('', 'new value');
Last updated 1 year ago.

I use something different so that I can keep other emails configurations apart from default (app/config/mail.php).

I keep the new configuration at a place something like app/email/invoice_mail.php (with different username and password) and when I want to use that configuration, I do something like this :

$transport = Mail::getSwiftMailer()->getTransport();

Mail::alwaysFrom(Config::get('email/invoice_mail.from.address'), Config::get('email/'));




This way I can more configurations. But this works only when the default driver is also 'smtp' as the transport is registered while booting up.

Last updated 1 year ago.

Sign in to participate in this thread!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.