If you use Swiftmailer 2.3.3, you have the opportunity to make everything simple:
in .yml add options:
mailer2_transport: smtp mailer2_encryption: ssl mailer2_auth_mode: login mailer2_host: smtp.gmail.com mailer2_user: your@gmail.com mailer2_password: *******
In config.yml, make the changes:
swiftmailer: default_mailer: mailer mailers: mailer: transport: %mailer_transport% host: %mailer_host% username: %mailer_user% password: %mailer_password% encryption: %mailer_encryption% auth_mode: %mailer_auth_mode% mailer2: transport: %mailer2_transport% host: %mailer2_host% username: %mailer2_user% password: %mailer2_password% encryption: %mailer2_encryption% auth_mode: %mailer2_auth_mode%
In the code, if you write:
$mailer = $this->get('swiftmailer.mailer.mailer2');
You will get the settings from your section;
And if you write:
$mailer = $this->get('swiftmailer.mailer.default');
or
$mailer = $this->get('mailer');
You will use the settings from the default section;
source share