Have you tried overriding the config settings at runtime (untested):
\Config::set('services.mailgun.domain', 'your-mailgun-domain');
\Config::set('services.mailgun.secret', 'your-mailgun-key');
elite123 said:
Have you tried overriding the config settings at runtime (untested):
\Config::set('services.mailgun.domain', 'your-mailgun-domain'); \Config::set('services.mailgun.secret', 'your-mailgun-key');
This solution does not work (Laravel 5.4). I found out the hard way.
The above will only work if you update the configuration before the Mailgun driver is initialized.
Changing it after the driver has loaded it will still send it using the credentials that were in the config at the time the driver loaded.
You have to destroy the mailer instance and recreate it. I do this by comparing the email address we send from and if that isn't loaded, then I reload the configuration
if (Config::get('mail.driver') == 'mailgun') {
$domain = Functions::getDomainFromEmailAddress($from);
if (Config::get('services.mailgun.domain') != $domain) {
App::forgetInstance('mailer');
Mail::clearResolvedInstance('mailer');
Config::set('services.mailgun.domain', $domain);
}
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community