Postfix + Sendmail(Rails):邮件未发送

Postfix + Sendmail(Rails):邮件未发送

我有一个用于发送电子邮件的 rails 应用程序。它在我的其他 ubuntu 服务器上可以运行,但在这个服务器上不行。这是我在 /var/log 中的 mail.log:

    Sep  4 15:48:56 web2 postfix/qmgr[27071]: 18B6F8A8FB: from=<[email protected]>, size=4447, nrcpt=2 (queue active)
    Sep  4 15:48:56 web2 postfix/qmgr[27071]: B84A78A8CF: from=<>, size=2844, nrcpt=1 (queue active)
    Sep  4 15:48:56 web2 postfix/qmgr[27071]: B1FA98A8E4: from=<[email protected]>, size=14467, nrcpt=1 (queue active)
    Sep  4 15:48:56 web2 postfix/smtp[12151]: warning: per-session SASL client initialization: generic failure
    Sep  4 15:48:56 web2 postfix/smtp[12151]: fatal: SASL per-connection initialization failed
    Sep  4 15:48:56 web2 postfix/smtp[12153]: warning: per-session SASL client initialization: generic failure
    Sep  4 15:48:56 web2 postfix/smtp[12153]: fatal: SASL per-connection initialization failed
    Sep  4 15:48:56 web2 postfix/smtp[12152]: warning: per-session SASL client initialization: generic failure
    Sep  4 15:48:56 web2 postfix/smtp[12152]: fatal: SASL per-connection initialization failed
    Sep  4 15:48:57 web2 postfix/qmgr[27071]: warning: private/smtp socket: malformed response
    Sep  4 15:48:57 web2 postfix/qmgr[27071]: warning: transport smtp failure -- see a previous warning/fatal/panic logfile record for the problem description
    Sep  4 15:48:57 web2 postfix/master[1000]: warning: process /usr/lib/postfix/smtp pid 12151 exit status 1
    Sep  4 15:48:57 web2 postfix/master[1000]: warning: /usr/lib/postfix/smtp: bad command startup -- throttling
    Sep  4 15:48:57 web2 postfix/error[12113]: 18B6F8A8FB: to=<[email protected]>, relay=none, delay=84547, delays=84546/1.1/0/0, dsn=4.3.0, status=deferred (unknown mail transport error)
    Sep  4 15:48:57 web2 postfix/error[12113]: 18B6F8A8FB: to=<[email protected]>, relay=none, delay=84547, delays=84546/1.1/0/0, dsn=4.3.0, status=deferred (unknown mail transport error)
    Sep  4 15:48:57 web2 postfix/qmgr[27071]: warning: private/smtp socket: malformed response
    Sep  4 15:48:57 web2 postfix/qmgr[27071]: warning: transport smtp failure -- see a previous warning/fatal/panic logfile record for the problem description
    Sep  4 15:48:57 web2 postfix/master[1000]: warning: process /usr/lib/postfix/smtp pid 12153 exit status 1
    Sep  4 15:48:57 web2 postfix/error[12113]: B1FA98A8E4: to=<[email protected]>, relay=none, delay=256639, delays=256637/1.2/0/0, dsn=4.3.0, status=deferred (unknown mail transport error)
    Sep  4 15:48:57 web2 postfix/qmgr[27071]: warning: private/smtp socket: malformed response
    Sep  4 15:48:57 web2 postfix/qmgr[27071]: warning: transport smtp failure -- see a previous warning/fatal/panic logfile record for the problem description
    Sep  4 15:48:57 web2 postfix/master[1000]: warning: process /usr/lib/postfix/smtp pid 12152 exit status 1
    Sep  4 15:48:57 web2 postfix/error[12113]: B84A78A8CF: to=<[email protected]>, relay=none, delay=99654, delays=99652/1.2/0/0, dsn=4.3.0, status=deferred (unknown mail transport error)

我对 Postfix 以及配置它的方式不太熟悉。我可以telnet localhost 25毫无问题地进行配置。有人能帮我调试一下吗?

如果您需要更多信息,请告诉我。

答案1

我认为我之前曾看到过相同类型的消息(“SASL 客户端初始化:通用故障”),以下是对我有用的配置。造成差异的选项是 enable_starttls_auto 和 openssl_verify_mode。

这是config/configuration.ymlRedmine 安装文件。我不是 Rails 专家,不确定其他 Rails 应用程序的配置是否相同 - 可能只适用于那些使用 ActionMailer 发送邮件的应用程序。

您可以在 Rails 文档中找到更多信息:http://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration

但是我刚刚发现 openssl_verify_mode 选项没有记录,一些信息可以在这里找到:https://rails.lighthouseapp.com/projects/8994/tickets/6508-undocumented-actionmailer-openssl_verify_mode-option

# default configuration options for all environments
default:
  # Outgoing emails configuration (see examples above)
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      enable_starttls_auto: false
      openssl_verify_mode: 'none'
      address: your.mailserver.com
      port: 587
      domain: yoursenderdomain.com
      authentication: :login
      user_name: "username"
      password: "password"

相关内容