Support the ongoing development of Laravel.io →
Configuration Mail Architecture
Last updated 2 years ago.
0

Have you tried to update config array on the fly?

Last updated 2 years ago.
0

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');
Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.