Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29755

Laravel update email config on the fly

$
0
0

I need to be able to send email using Mailgun from one domain, switch settings, then send another from another domain. However, updating the settings before sending the second email does not work, the second email still gets sent using the first emails settings.

Initial settings are set in Config.mail and Config.services, this all works fine.

// send first email
try { 
    Mail::send(--stuff here--) 
} catch (Exception $e) { ... }

// update config using the sandbox account details
Config::set('mail.username', 'postmaster@secret.mailgun.org');
Config::set('mail.password', 'password');
Config::set('services.mailgun.domain', 'domain.mailgun.org'); 
Config::set('services.mailgun.secret', 'key-secret');

// send second email
try { 
    Mail::send(--stuff here--) 
} catch (Exception $e) { ... }
// Second email has now been sent using the first emails config settings 

If I comment out the first email send, then change the settings as above, the second email get's sent correctly from the sandbox account. If I leave the first email in, it gets sent from a domain I have on MailGun.

Does anyone have any experience with this?


Viewing all articles
Browse latest Browse all 29755

Trending Articles