php - Laravel update email config on the fly -
i need able send email using mailgun 1 domain, switch settings, send another domain. however, updating settings before sending second email not work, second email still gets sent using first emails settings.
initial settings set in config.mail
, config.services
, works fine.
// send first email try { mail::send(--stuff here--) } catch (exception $e) { ... } // update config using 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 been sent using first emails config settings
if comment out first email send, change settings above, second email get's sent correctly sandbox account. if leave first email in, gets sent domain have on mailgun.
does have experience this?
config([ 'mail.host' => 'smtp.yandex.ru', 'mail.port' => 465, 'mail.encryption' =>'ssl', 'mail.username' => 'username', 'mail.password' => 'password' ]); $app = app::getinstance(); $app['swift.transport'] = $app->share(function ($app) { return new transportmanager($app); }); $mailer = new \swift_mailer($app['swift.transport']->driver()); mail::setswiftmailer($mailer); $msg = mail::send('mail.view', ['key' => 'value'], function(message $message) { $message ->to('user@mail.com', 'name') ->subject('subject'); });
Comments
Post a Comment