In my case, the problem was with SSL. My SMTP has a self-signed certificate, and my laravel runs on top of PHP 5.6, which disables the context variable allow_self_signed to false and allows "verify_peer" and therefore gives an error when sending emails.
Since I did not want to crack the swiftmailer code, I added my Server Certificate Authority (CA) file as a trusted CA for my system running laravel.
I did this by getting my smtp server CA certificate, something like
-----BEGIN CERTIFICATE----- MIIElTCCA32gAwIBAgIJAMZjjNg64RQwMA0GCSqGSIb3DQEBCwUAMIGNMQswCQYD VQQGEwJVUzEMMAoGA1UECBMDTi9BMQwwCgYDVQQHEwNOL0ExJDAiBgNVBAoTG1pp ... 5a8a4QEwWmnAOgHetsOCvhfeGW3yAJPD8Q== -----END CERTIFICATE-----
and write it in my laravel machine which has Ubuntu 14.04 for a file named /usr/local/share/ca-certificates/my_cert.crt . It is imperative to complete the .crt file as well as make it accessible to everyone.
Then call update-ca-certificates , and the certificate will be added to the list of valid certificate authorities of your server.
source share