2
votes

Trying to send email with Swiftmailer, I got this error. I've configured swiftmailer with:

transport: smtp
host: smtp.gmail.com
username: [email protected]
password: password
port: 587
encryption: ssl

I always get this error message:

Connection could not be established with host smtp.gmail.com


I've also tried with:

transport: gmail
host: smtp.gmail.com
username: [email protected]
password: password
port: 587
encryption: ssl

The complete error message is

[YYYY-mm-dd hh:ii:ss] app.ERROR: Exception occurred while flushing email queue: Connection could not be established with host smtp.gmail.com [ #0]


Other questions:

My case is different from this. In my case I've not Avast antivirus.


EDIT: changing port to 465, as Alex Howansky suggested, erro changes in

Exception occurred while flushing email queue: Failed to authenticate on SMTP server with username "my email address" using 1 possible authenticators

2
Port 587 is not SSL. You probably want port 465. See here.Alex Howansky
You might need to toggle the "Use Less Secure Apps" setting as described here.Alex Howansky
Already done. Thank you for the suggestion.sensorario
Is your username a gmail account, or is it something else?skagzilla

2 Answers

0
votes

1: Either you must allow less secure apps or use app password by enabling 2 step verification on your gmail acc. 2: Disable any antivirus on your machine(this is something no one will tell u but is necessary in many cases). 3: Don't forget to clear your cache (sometimes it don't take updated content from .env file) 4: You don't need to change anything in Mailer inside config directory(not recommended), you should use env variables

-1
votes

it's looking for the server smtp.gmail.com but isn't able to resolve it. use this domain smtp.gmail.com and port 25 or 465.