multiple mail configurations

后端 未结 7 514
遇见更好的自我
遇见更好的自我 2020-11-28 07:13

I configured laravel\'s mail service with mandrill driver. No problems here!

Now, at certain point of my application, I need to send a mail via gmail.

I did

相关标签:
7条回答
  • 2020-11-28 07:58

    For Laravel 6 you should use it like this:

    // Backup your default mailer
    $backup = Mail::getSwiftMailer();
    
    // Setup your gmail mailer
    $gmail = new \Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl');
    
    // Set the mailer as gmail
    Mail::setSwiftMailer(new \Swift_Mailer($gmail));
    
    // Send your message
    Mail::send();
    
    // Restore your original mailer
    Mail::setSwiftMailer($backup);
    
    0 讨论(0)
提交回复
热议问题