"cannot connect to smtp.gmail.com, port 587: Connection timed out"

July 25, 2017 298 views
Apache DigitalOcean Development PHP Email Ubuntu 16.04

Hi,

I tried this tutorial in order to enabling the email sending facility to the website which is on Droplets.

This worked fine in localhost and email sent/received very quickeley but it doesn't work in Droplet.:(

This is the error message (when- tail /var/log/msmtp.log)

Jul 25 06:39:08 host=smtp.gmail.com tls=on auth=on user=aleem.firnas22gmail.com from=aleem.firnas22@gmail.com recipients=aleem.firnas22@gmail.com errormsg='cannot connect to smtp.gmail.com, port 587: Connection timed out' exitcode=EX_TEMPFAIL

Please help me :(

Thanks.

1 comment
2 Answers

Hi @aleemfirnas22

If your account with DigitalOcean is new, then all SMTP actions are blocked and you need to create a ticket with Support via the control panel and ask to un-block SMTP.
This is to prevent SPAM.

  • Hi,

    Thanks @hansen I created a ticket as you suggested, could enabled mail-related traffic to my account.

    This is the tutorial I followed tutorial link , worked in local machine, now again the same problem persists. After clicked on the send button in the form from (www.amfirnas.me) it's loading some time but not recieved the email.

    Here is the php.ini settings in droplet

    [mail function]
    ; For Win32 only.
    ; http://php.net/smtp
    SMTP = localhost
    ; http://php.net/smtp-port
    smtp_port = 25
    
    ; For Win32 only.
    ; http://php.net/sendmail-from
    ;sendmail_from = me@example.com
    
    ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
    ; http://php.net/sendmail-path
    sendmail_path = "/usr/bin/msmtp -C /etc/.msmtp_php --logfile /var/log/msmtp.log -a gmail -t"
    

    Thanks

    Read through this tutorial to learn how to use Gmail or Yahoo with PHP mail() function.
    • @aleemfirnas22
      I don't know msmtp, but if your account has a SMTP-block, then that would mean any type of SMTP traffic coming from your server is blocked.

@aleemfirnas22

How did it work on localhost? What tutorial did you follow?

Have another answer? Share your knowledge.