Skip to content

Instantly share code, notes, and snippets.

@oiljin
Created February 17, 2016 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oiljin/fa5dbe6f39687596b501 to your computer and use it in GitHub Desktop.
Save oiljin/fa5dbe6f39687596b501 to your computer and use it in GitHub Desktop.
Laravel update email config on the fly
<?php
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');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment