Net :: OpenTimeout exception (expired) using Rails mailer

I have a problem with delivering letters to the production server. When the mailer processes a new message, it throws a Net::OpenTimeout (execution expired) exception

My smtp settings:

 #settings.yml production: smtp: address: smtp.gmail.com port: 587 domain: mydomain.net user_name: username@gmail.com password: password authentication: plain enable_starttls_auto: true 

My environment settings:

  #production.rb config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = Settings.smtp.symbolize_keys 

From the magazines:

 Sent mail to username@gmail.com (30010.1ms) I, [2014-10-15T12:59:22.371563 #19779] INFO -- : Completed 500 Internal Server Error in 30051ms F, [2014-10-15T12:59:22.373984 #19779] FATAL -- :. Net::OpenTimeout (execution expired): app/controllers/subscribers_controller.rb:9:in `create' 
+5
source share
2 answers

My VPS (DigitalOcean) provider blocked SMTP on IPv6 by default: (

I had to disable IPv6 on the server with the following configuration:

 # /etc/sysctl.conf net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 

Apply Settings:

 $ sysctl -p 

Uncomment the following line in /etc/gai.conf to prefer IPv4:

 precedence ::ffff:0:0/96 100 

And remove IPv6 DNS from /etc/resolv.conf :

 nameserver 2001:4860:4860::8844 # remove lines like this nameserver 8.8.8.8 #don't remove 

Then restart the application and Nginx (optional)

+6
source

I had the same problem, in my case it was due to the fact that the Google Cloud Compute platform blocks outgoing connections to SMTP servers outside the Google domain on ports 25, 465 and 587.

To fix this problem, we had to connect to a non-standard SMTP port (most of the default API-based email platforms support 2525).

+3
source

Source: https://habr.com/ru/post/1204754/


All Articles