Multiple email server configuration

Submitted by aglipanci - 9 years ago

Change email configuration on the fly.

use \Swift_Mailer;
use \Swift_SmtpTransport as SmtpTransport;


// Setup a new SmtpTransport instance for Gmail 
$transport = SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl');
$transport->setUsername('you@gmail.com');
$transport->setPassword('yourpassword123');

// Assign a new SmtpTransport to SwiftMailer
$gmail = new Swift_Mailer($transport);

// Assign it to the Laravel Mailer
Mail::setSwiftMailer($gmail);

// Send your message
Mail::send();