【发布时间】:2014-11-13 12:47:29
【问题描述】:
谷歌计算引擎上的 Ubuntu 14.04 实例应该托管通过Passenger/nginx 服务的rails3 应用程序。该实例已安装 sendmail。 GCE 实例有防火墙规则
Source Ranges: 0.0.0.0/0 Allowed Protocols or Ports: tcp:2525
已建立并配置为通过 sendgrid 发送邮件。 telnet smtp.sendgrid.net 2525 确实连接并允许通过该连接发送电子邮件。所以交通应该畅通。
但是,以下任何一种组合都不会超时。 Nginx 日志不会发现错误,但应用程序的日志确实指出已达到超时。
调用:
ActionMailer::Base.smtp_settings =
config.action_mailer.smtp_settings =
其次是基本集团
{
:user_name => 'user',
:password => 'aaabbbb',
:domain => 'domain.tld',
:address => 'smtp.sendgrid.net',
:port => 2525,
:authentication => :plain,
:enable_starttls_auto => true
}
在每个environment.rb, application.rb, environments/development.rb中都尝试过
在设置块之前或之后添加这些块中的一个或两个块:
config.action_mailer.default_url_options = {
:host => 'smtp.sendgrid.net',
:port => 2525
}
config.action_mailer.delivery_method = :smtp
对整体行为没有影响。这是具有相同行为的 8 个组合。由于无法访问 GCE 日志来处理这些传出消息,我不知道它们是否真正正确地离开了应用程序。
坦率地说,GCE 的这种障碍有点令人震惊,恕我直言。
** 编辑 ** 从控制台启动返回以下错误堆栈:
Timeout::Error: execution expired
from /home/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/net/smtp.rb:541:in `initialize'
from /home/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/net/smtp.rb:541:in `open'
from /home/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/net/smtp.rb:541:in `tcp_socket'
from /home/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/net/smtp.rb:550:in `block in do_start'
from /home/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/net/smtp.rb:550:in `do_start'
from /home/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/net/smtp.rb:520:in `start'
from /home/user/app/shared/bundle/ruby/1.9.1/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
from /home/user/app/shared/bundle/ruby/1.9.1/gems/mail-2.5.4/lib/mail/message.rb:2129:in `do_delivery'
from /home/user/app/shared/bundle/ruby/1.9.1/gems/mail-2.5.4/lib/mail/message.rb:232:in `block in deliver'
from /home/user/app/shared/bundle/ruby/1.9.1/gems/actionmailer-3.2.18/lib/action_mailer/base.rb:415:in `block in deliver_mail'
from /home/user/app/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.18/lib/active_support/notifications.rb:123:in `block in instrument'
[...]
更新
感谢 marilu 指出 /var/log/syslog。
这些操作根本没有引用它。所以是的,这是一个 Rails 配置问题。
【问题讨论】:
-
您是否尝试过从命令行发送电子邮件?如果这有效,那么它可能是您在 Rails 中的配置。在文件 /var/log/syslog 中,您可以查看发送电子邮件时是否收到错误。
标签: ruby-on-rails-3.2 google-compute-engine sendgrid