Search code examples
laravelemailsmtplampdigital-ocean

Can't Send Email From Laravel Application : Connection could not be established with host smtp.gmail.com [Connection timed out #110]


I'm using digital ocean ubuntu machine & i want to send the forget password email

but every time i send the email this error shows up using these settings :

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=info@example.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls

enter image description here

the strange thing is that it's working without any problems in my local environment using the same settings

by the way my info@example.com is a Gsuite account and it's working

i know some people would tell me to use

MAIL_DRIVER=sendmail

but everytime it sends the email it goes directly to the spam folder

i added the spf record

v=spf1 +a +ip4:xx.xxx.xx.xxx ~all

I Followed : https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-dkim-with-postfix-on-debian-wheezy

and added the record v=DKIM1; k=rsa; p='very long key'

and still goes to the spam folder

i don't know what to do i want to use the google smtp or use sendmail or any other method just to send the email right into the normal inbox

please help ,thank you


Solution

  • after a lot of digging and opening a ticket in digital ocean support center

    the solution was to change my droplet name to the same domain name to have a valid ptr record

    it took about a day to work