2

im trying to send a email with action mailer and it gives me a Timeout::Error (execution expired): even though in the console it says that the e mail is sent: it shows

    Sent mail to aldeirm2@gmail.com

then displayes the e mail that was sent then it shows the following error:

Timeout::Error (execution expired):
  /usr/lib/ruby/1.8/timeout.rb:60:in `open'
  /usr/lib/ruby/1.8/net/smtp.rb:551:in `do_start'
  /usr/lib/ruby/1.8/net/smtp.rb:551:in `do_start'
  /usr/lib/ruby/1.8/net/smtp.rb:525:in `start'
  app/models/appointment.rb:10:in `tomorrows_appointments'
  app/models/appointment.rb:8:in `each'
  app/models/appointment.rb:8:in `tomorrows_appointments'
  app/controllers/show_appointments_controller.rb:11:in `send_email'
  -e:2:in `load'
  -e:2

Rendered rescues/_trace (35.8ms)
Rendered rescues/_request_and_response (0.3ms)
Rendering rescues/layout (internal_server_error)

here is my settings:

config.cache_classes = false
config.whiny_nils = true
config.action_controller.consider_all_requests_local = true
config.action_view.debug_rjs                         = true
config.action_controller.perform_caching             = false

config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :enable_starttls_auto => true,
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domian               => "gmail.com",
  :authentication       => :login,
  :user_name            => "username",
  :password             => "blablabla",
}

i also tried setting authentication to :plain and using username@gmail.com as the user_name with no hope.

any ideas

4

3 回答 3

3

我在那里看到一个错字:你写了 :domian => "gmail.com",

代替

:domain => "gmail.com",

于 2011-01-24T12:52:50.353 回答
1

SMTP 请求似乎偶尔会超时,这可能取决于您设置的超时时间。您将遇到的另一个问题是,当用户等待您的服务器与 Gmail 的 SMTP 服务器通信时,网络应用程序出现延迟。

我知道 gmail 是新 Rails 应用程序的流行选项,但我认为这不是一个长期的解决方案,因为您必须通过具有每日发送限制的特定 gmail 帐户发送邮件。即使使用其他帐户,我也发现 SMTP 超时是一个问题。

现在我正在使用 SendGrid 发送电子邮件,并发现通过 postfix 使用 sendgrid 作为中继主机是有利的选择。这意味着用户可以更快地从 web 应用程序获得响应,并且邮件通过 postfix 排队,然后通过 sendgrid 发送(因此不再有超时!)。

有关 sendgrid 的后缀设置说明,请参见此处: http ://wiki.sendgrid.com/doku.php?id=postfix

然后,在您的 Rails 环境中,您只需要以下内容:

config.action_mailer.delivery_method = :sendmail
config.action_mailer.sendmail_settings = {
  :location       => '/usr/sbin/sendmail',
  :arguments      => '-i -t'
}
于 2010-08-02T08:58:19.027 回答
1

如果其他人有同样的问题:

确保您的防火墙允许到端口 587 的传出连接

对于iptables,您可以列出所有现有规则:

sudo iptables -L

这里查看必要的规则。

如果您使用的是AWS 实例,请查看您的安全组。

于 2014-05-22T15:26:01.753 回答