Send email with changed mailer config

Hi! I need to send a custom email using a different SMTP account than the one configured for the entire site (in Mail Settings). I created a plugin settings page with fields: “host”, “port”, “username”, “password”, etc. How can I use this custom configuration when I use Mail::send();?

Could this help?

1 Like

Yes, this can be helpful, but in my case I did something simpler.

  1. I added a new mailer smtp_newsletter in config/mail.php
  2. I set the configuration for this mailer with values ​​from the plugin settings using Config::set('mail.mailers.smtp_newsletter', []);
  3. To send messages I use Mail::mailer('smtp_newsletter')->send();
2 Likes