For some reason, I was having a huge problem using Gmail's SMTP with Symfony2's Swiftmailer out of the box. With the default configuration Symfony2 throws at you, it makes sense just to plug in your user, password, server, SSL port and go, right? Well it wasn't the case for me. Sometimes it would send the mail, but most of the time Gmail's servers would refuse the connect. Why? Who knows.
This wasn't in the offical documentation and it took me a bit to figure it out, so I thought I'd share.
Swiftmailer actually has a custom mailer transport for gmail! Guess what? Works like a charm. So instead of manually putting every single option in there for Gmail, we'll just change the transport and enter our username and password. DONE!
mailer_transport: gmail mailer_user: email@example.com mailer_password: supercoolpassword
# Swiftmailer Configuration swiftmailer: transport: "%mailer_transport%" username: "%mailer_user%" password: "%mailer_password%"
That's it! You don't need port, server, encryption settings or anything. Swiftmailer will handle everything.