Search code examples
laravelgmailswiftmailer

Sending email from Laravel using Gmail


I have been using Laravel for a little while now, so thought I would dive into HTML emails, so I followed a tutorial.

The issue I have, as well as seemingly quite a few others is this:

Swift_TransportException in StreamBuffer.php line 269:

Connection could not be established with host smtp.gmail.com 
[A connection attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because connected host has  failed to respond.
#10060]

My .ENV

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=EMAIL
MAIL_PASSWORD=PASS
MAIL_ENCRYPTION=tls

I have also tried ports 25 and others suggested, as well as ssl as opposed to tls, I have also tried using sendmail as opposed to smtp.

Further to this, I have the same issue when trying with an Outlook account.

I even enabled the option to accept items from less secure applications.

Anyone else experiencing these issues?

UPDATE:

I am having the same issues with Mail Trap, could it be my laravel install?

Also tried with a fresh install...

FURTHER UPDATE

When I ping any site, I get request timed out, which means I think my router is blocking me?


Solution

  • According with help for administrator page of Google, when you try to connect by port 465 this requires encryption SSL, on the contrary if you use TLS you should set the port to 587, try changing the port on your .env file.

    Reference: https://support.google.com/a/answer/176600?hl=es