Reputation: 85
I'm using swiftmailer-bundle for sending emails from my applications
I have added this in env.
MAILER_URL=gmail://[email protected]:mypassword@localhost?encryption=tls&auth_mode=oauth
And this when i need to sent the email from controller
$message = (new \Swift_Message($objet))
->setFrom('[email protected]','example')
->setTo([email protected])
->setBody("test")
)
My question is how to add another mail?, i need to use more than one mail
Can i add two lines of MAILER_URL in env. ??
Upvotes: 1
Views: 1109
Reputation: 1311
Check out the official documentation on using multiple mailers.
https://symfony.com/doc/current/reference/configuration/swiftmailer.html#using-multiple-mailers
swiftmailer:
default_mailer: first_mailer
mailers:
first_mailer:
url: '%env(MAILER_URL)%'
second_mailer:
url: '%env(SECOND_MAILER_URL)%'
// returns the first mailer
$container->get('swiftmailer.mailer.first_mailer');
// returns the second mailer
$container->get('swiftmailer.mailer.second_mailer');
Upvotes: 2