【问题标题】:Postfix & Rails 3.0 ActionMailer: lost connection after STARTTLSPostfix & Rails 3.0 ActionMailer:STARTTLS 后失去连接
【发布时间】:2011-02-21 05:20:52
【问题描述】:

我在开发模式下使用 Ruby 1.9.2 和 Rails 3.0.4,我正在尝试将其配置为从安装在同一个盒子上的 Postfix 服务器发送电子邮件(运行 Ubuntu 10.04 并安装了 dovecot-postfix 包) 每当我尝试从 Rails 发送电子邮件时,它都会在 Rails 中顺利通过,但在 Postfix 日志中显示错误(我已从下面的摘录中删除了域和 IP):

Feb 21 04:49:16 alpha postfix/smtpd[9060]: connect from alpha.mydomain.com[xxx.xxx.xxx.xxx]
Feb 21 04:49:16 alpha postfix/smtpd[9060]: lost connection after STARTTLS from alpha.mydomain.com[xxx.xxx.xxx.xxx]
Feb 21 04:49:16 alpha postfix/smtpd[9060]: disconnect from alpha.mydomain.com[xxx.xxx.xxx.xxx]

奇怪的是,当我从 Thunderbird 等电子邮件客户端连接到 SMTP 服务器时,它可以正常工作。

我知道开发模式有时不允许发送电子邮件,所以我在 environment/development.rb 文件中添加了以下内容:

config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true

 #load mail server settings
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address              => "mail.mydomain.com",
  :port                 => 587,
  :domain               => 'mydomain.com',
  :user_name            => 'username',
  :password             => 'password',
  :authentication       => 'plain',
  :tls  => true,
  :enable_starttls_auto => true  }

【问题讨论】:

  • 我做了更多的挖掘工作并在 Postfix 日志中启用了更详细的信息。我现在看到显示“503 5.5.1 错误:身份验证未启用”的日志,但我在后缀配置中启用了 SASL

标签: email ruby-on-rails-3 actionmailer postfix-mta


【解决方案1】:

如果您只是从 localhost 发送电子邮件,那么您不需要 SMTP 以及随之而来的所有身份验证问题。您可以直接使用 sendmail 发送。

config.action_mailer.delivery_method = :sendmail

【讨论】:

    【解决方案2】:

    是否有可能您的证书无效,并且 Thunderbird 在发送电子邮件时回退到普通 SMTP?尝试在您的配置中禁用 TLS。

    【讨论】:

    • 我在 Postfix 的 main.cf 中为 smtp 和 smtpd 禁用了 TLS,然后从 rails 配置中删除了 :tls 行并将 :enabled_starttls_auto 更改为 false。现在我得到“AUTH 后失去连接”
    • 也许您没有权限从您的 IP(可能是 localhost (127.0.0.1))连接到服务器?检查你的 main.cf Postfix 配置文件。
    • 我设法用这个来修复它:davidroetzel.wordpress.com/2011/01/14/… 我什至从阅读一些 ActionMailer 文档时都不知道该选项存在。原来它使用的 SSL 证书有问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-26
    • 2016-04-22
    • 1970-01-01
    • 2015-09-20
    • 2013-05-07
    • 2023-01-23
    相关资源
    最近更新 更多