异常与Rails邮件程序有关

异常与Rails邮件程序有关

本文介绍了Net :: OpenTimeout(执行过期)异常与Rails邮件程序有关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在生产服务器上传递电子邮件时遇到问题。
邮件处理新消息时,调用异常 Net :: OpenTimeout(执行已过期)

I have problem with delivering emails on production server.When mailer processed new message, calls exception Net::OpenTimeout (execution expired)

我的smtp设置:

#settings.yml
production:
  smtp:
    address:        smtp.gmail.com
    port:           587
    domain:         mydomain.net
    user_name:      [email protected]
    password:       password
    authentication: plain
    enable_starttls_auto: true

我的环境设置:

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

来自日志:

Sent mail to [email protected] (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'


推荐答案

我的VPS提供程序(DigitalOcean)默认情况下在IPv6上阻止了SMTP:(

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

I必须在具有下一个配置的服务器上禁用IPv6:

I had to disable IPv6 on server with next config:

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

应用设置:

$ sysctl -p

取消注释 /etc/gai.conf 中的下一行首选IPv4:

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

precedence ::ffff:0:0/96 100

并从 /etc/resolv.conf 中删除​​IPv6 DNS:

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

然后重新启动应用程序和Nginx (可选)

Then restart application and Nginx (optional)

这篇关于Net :: OpenTimeout(执行过期)异常与Rails邮件程序有关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 23:16