Rails Mailer “Net::OpenTimeout: execution expired” Exception on production server only

前端 未结 8 1289
南方客
南方客 2020-12-05 04:19

I am using Ruby MRI 2.0.0 and Rails 3.2.12 on a Ubuntu 12.04 TLS VPS and attempting to setup email notifications in my app. It was working fine a few days ago, but n

相关标签:
8条回答
  • 2020-12-05 05:02

    First, do a direct connection with Telnet:

    telnet smtp-relay.sendinblue.com 587
    Trying 94.143.17.4...
    

    This is the basic connection troubleshooting, and works with any provider or port. Replace SendBlue and the 587 port with your actual hostname/port.

    If you get this error:

    telnet: Unable to connect to remote host: Connection timed out
    

    then, the problem isn't in Rails.

    In the above example, the problem is in the port number. Services like sendinblue or mandrill (I believe gmail too) don't support the 587 port anymore. "2525" is the new "587".


    If you get a timeout on telnet, check this:

    1. hostname: it's usual to people use "smtp.sendinblue.com" instead of "stmp-relay.sendinblue.com", "smtp.mandrill.com" instead of "smtp.mandrillapp.com", and so on.
    2. port: 587 is obsolete. Major providers are now using 2525 instead. Major cloud services like DigitalOcean, block outgoing connections to 587 as well. That's why it will work on your pc, but not on your server. I won't even mention the "25" port, which is even more obsolete than 587. Also, some providers use specific non-default ones instead or imap.
    3. ipv6 vs ipv4: check if the hostname is being translated as a IPv4. If not, try to disable IPv6 (see others answers).
    4. hostname resolution: run the same telnet command on a machine that you know the email sending is working. Check if the translated ip (the xxx part of "Trying xxx...") is the same. If not, go back to your server and replace the hostname with this ip. If works, change your /etc/hosts and force the hostname to use this ip.
    0 讨论(0)
  • 2020-12-05 05:05

    If you (or the internet in this case as this question is the first result for this problem) are testing Mailgun, you may get this error if you're using port 25. Change the port to 587 worked, even though their docs/quick links says 25 is ok to use.

    0 讨论(0)
提交回复
热议问题