Have you tried to update config array on the fly?
You could update mail.php
with something like:
'host' => Config::get('mail.sender.host'),
'user' => Config::get('mail.sender.user'),
etc...
If you need to update the config values at runtime you can do it with:
Config::set('mail.sender.host', 'new value');
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/invoice_mail.from.name'));
$transport->setUsername(Config::get('email/invoice_mail.username'));
$transport->setPassword(Config::get('email/invoice_mail.password'));
Mail::send(......);
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.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community