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

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');

http://laravel.com/docs/5.0/configuration

0

Will try, thanks.

0

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');

http://laravel.com/docs/5.0/configuration

This solution does not work (Laravel 5.4). I found out the hard way.

0

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.

0

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);
		}
	}
Last updated 7 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.