ruby-on-rails - Action Mailer 无法与 sendmail 一起使用

标签 ruby-on-rails sendmail actionmailer postfix-mta

我正在尝试使用 sendmail 发送邮件。发送邮件时,日志中没有任何错误,但是当我查看邮箱时,邮件不在那里,甚至在垃圾邮件文件夹中。
我从 var/log 目录中的 mail.log 文件中获得了一些信息,但无法真正弄清楚我必须更改什么才能使其正常工作。

这是我的 development.rb 部分:

config.action_mailer.delivery_method = :sendmail
config.action_mailer.raise_delivery_errors = true

我尝试使用两个不同的地址并收到不同的消息:
这是来自我的mail.log:
Feb 16 13:55:22 localhost postfix/master[2821]: daemon started -- version 2.8.4, configuration /etc/postfix  
Feb 16 13:55:22 localhost postfix/pickup[2822]: 5E1C6CB8C1: uid=501 from=<fhu@informatik.uni-kiel.de>  
Feb 16 13:55:22 localhost postfix/cleanup[2824]: 5E1C6CB8C1: message-id=<4f3cfcba50ccf_ac695d96210305e1@localhost.mail>  
Feb 16 13:55:22 localhost postfix/qmgr[2823]: 5E1C6CB8C1: from=<fhu@informatik.uni-kiel.de>, size=882, nrcpt=1 (queue active)  
Feb 16 13:55:27 localhost postfix/smtp[2826]: 5E1C6CB8C1: to=<mkh@informatik.uni-kiel.de>, relay=miraculix.informatik.uni-kiel.de[134.245.248.198]:25, delay=5.3, delays=0.04/0.01/5.3/0.04, dsn=5.7.1, status=bounced (host miraculix.informatik.uni-kiel.de[134.245.248.198] said: 550 5.7.1 HELO localhost.localhost from RFC 2606 reserved domains blocked (in reply to MAIL FROM command))  
Feb 16 13:55:27 localhost postfix/cleanup[2824]: C0D2ACB8CB: message-id=<20120216125527.C0D2ACB8CB@localhost.localhost>  
Feb 16 13:55:27 localhost postfix/bounce[2829]: 5E1C6CB8C1: sender non-delivery notification: C0D2ACB8CB  
Feb 16 13:55:27 localhost postfix/qmgr[2823]: C0D2ACB8CB: from=<>, size=2932, nrcpt=1 (queue active)  
Feb 16 13:55:27 localhost postfix/qmgr[2823]: 5E1C6CB8C1: removed  
Feb 16 13:55:33 localhost postfix/smtp[2826]: C0D2ACB8CB: to=<fhu@informatik.uni-kiel.de>, relay=miraculix.informatik.uni-kiel.de[134.245.248.198]:25, delay=5.2, delays=0/0/5.2/0.04, dsn=5.7.1, status=bounced (host miraculix.informatik.uni-kiel.de[134.245.248.198] said: 550 5.7.1 HELO localhost.localhost from RFC 2606 reserved domains blocked (in reply to MAIL FROM command))  
Feb 16 13:55:33 localhost postfix/qmgr[2823]: C0D2ACB8CB: removed  

第二个地址:
Feb 16 13:56:22 localhost postfix/master[2821]: master exit time has arrived  
Feb 16 13:58:30 localhost postfix/master[2835]: daemon started -- version 2.8.4, configuration /etc/postfix  
Feb 16 13:58:30 localhost postfix/pickup[2836]: 91FFCCB947: uid=501 from=<xxx@informatik.uni-kiel.de>  
Feb 16 13:58:30 localhost postfix/cleanup[2838]: 91FFCCB947: message-id=<4f3cfd7684947_ac695dc9a5c306de@localhost.mail>  
Feb 16 13:58:30 localhost postfix/qmgr[2837]: 91FFCCB947: from=<xxx@informatik.uni-kiel.de>, size=878, nrcpt=1 (queue active)  
Feb 16 13:58:30 localhost postfix/smtp[2840]: connect to mx.freenet.de[2001:748:100:40::8:110]:25: No route to host  
Feb 16 13:58:30 localhost postfix/smtp[2840]: connect to mx.freenet.de[2001:748:100:40::8:112]:25: No route to host  
Feb 16 13:58:30 localhost postfix/smtp[2840]: connect to mx.freenet.de[2001:748:100:40::8:111]:25: No route to host  
Feb 16 13:58:30 localhost postfix/smtp[2840]: 91FFCCB947: to=<xxx@freenet.de>, relay=mx.freenet.de[195.4.92.9]:25, delay=0.32, delays=0.04/0.01/0.23/0.04, dsn=5.0.0, status=bounced (host mx.freenet.de[195.4.92.9] said: 550 Submission from dynamic IP 82.83.107.102 requires authentication (in reply to RCPT TO command))  
Feb 16 13:58:30 localhost postfix/cleanup[2838]: DF128CB94C: message-id=<20120216125830.DF128CB94C@localhost.localhost>  
Feb 16 13:58:30 localhost postfix/bounce[2843]: 91FFCCB947: sender non-delivery notification: DF128CB94C  
Feb 16 13:58:30 localhost postfix/qmgr[2837]: DF128CB94C: from=<>, size=2864, nrcpt=1 (queue active)  
Feb 16 13:58:30 localhost postfix/qmgr[2837]: 91FFCCB947: removed  
Feb 16 13:58:36 localhost postfix/smtp[2840]: DF128CB94C: to=<xxx@informatik.uni-kiel.de>, relay=miraculix.informatik.uni-kiel.de[134.245.248.198]:25, delay=5.3, delays=0/0/5.3/0.04, dsn=5.7.1, status=bounced (host miraculix.informatik.uni-kiel.de[134.245.248.198] said: 550 5.7.1 HELO localhost.localhost from RFC 2606 reserved domains blocked (in reply to MAIL FROM command))  
Feb 16 13:58:36 localhost postfix/qmgr[2837]: DF128CB94C: removed  
~              

在我的 user_mailer.rb 我有这个:
default :from => "xxx@informatik.uni-kiel.de"

我也试过
config.action_mailer.sendmail_settings = 
    { :arguments => '-i -t -f xxx@informatik.uni-kiel.de'}

那么 mail.log 仍然是这样的:
Feb 16 14:54:57 localhost postfix/master[2893]: daemon started -- version 2.8.4, configuration /etc/postfix  
Feb 16 14:54:57 localhost postfix/qmgr[2895]: 9DBF4CB857: from=<xxx@informatik.uni-kiel.de>, size=859, nrcpt=1 (queue active)
Feb 16 14:54:58 localhost postfix/pickup[2894]: A3120CC90B: uid=501 from=<xxx@informatik.uni-kiel.de>  
Feb 16 14:54:58 localhost postfix/cleanup[2896]: A3120CC90B: message-id=<4f3d0ab19405d_b4999f2bd74125b1@localhost.mail>  
Feb 16 14:54:58 localhost postfix/qmgr[2895]: A3120CC90B: from=<xxx@informatik.uni-kiel.de>, size=880, nrcpt=1 (queue active)  
Feb 16 14:54:58 localhost postfix/smtp[2906]: connect to mx.freenet.de[2001:748:100:40::8:111]:25: No route to host  
Feb 16 14:54:58 localhost postfix/smtp[2906]: connect to mx.freenet.de[2001:748:100:40::8:112]:25: No route to host  
Feb 16 14:54:58 localhost postfix/smtp[2906]: connect to mx.freenet.de[2001:748:100:40::8:110]:25: No route to host  
Feb 16 14:54:58 localhost postfix/smtp[2906]: A3120CC90B: to=<xxx@freenet.de>, relay=mx.freenet.de[195.4.92.212]:25, delay=1.3, delays=1/0.01/0.17/0.05, dsn=5.0.0, status=bounced (host mx.freenet.de[195.4.92.212] said: 550 Submission from dynamic IP 82.83.107.102 requires authentication (in reply to RCPT TO command))  
Feb 16 14:54:58 localhost postfix/cleanup[2896]: E3597CC90F: message-id=<20120216135458.E3597CC90F@localhost.localhost>  
Feb 16 14:54:58 localhost postfix/qmgr[2895]: E3597CC90F: from=<>, size=2868, nrcpt=1 (queue active)  
Feb 16 14:54:58 localhost postfix/bounce[2907]: A3120CC90B: sender non-delivery notification: E3597CC90F  
Feb 16 14:54:58 localhost postfix/qmgr[2895]: A3120CC90B: removed  
~                                                                            

我尝试 telnet mx.freenet.de 25 并获得连接。我真的很感激任何帮助。

谢谢!

最佳答案

ActionMailer 工作正常,并通过 sendmail api 将消息发送到 postfix。

但是 postfix 会弹回消息,因为 HELO 命令中的发件人机器名称是 localhost.localhost。

在 rails 中设置发件人的主机和名称,它应该会更好地工作。

docs

可能是您需要在操作系统级别(而不是 rails)设置主机。在 super 用户列表中询问。看看当你给 hostname 时会发生什么操作系统的命令。如果它返回“localhost.localhost”,那么这是要解决的第一个问题。

关于ruby-on-rails - Action Mailer 无法与 sendmail 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9311868/

相关文章:

ruby-on-rails - 我应该测试 gem 的功能吗?

javascript - Rails Jquery 在其他页面上不起作用

php - 邮件与发送邮件

ruby-on-rails - Action Mailer 模板的优雅降级/渐进增强?

ruby-on-rails - 使用 ActionMailer 发送多部分邮件时出现问题

ruby-on-rails - 使用 rspec 测试邮件程序 'from' header

ruby-on-rails - 在 AccessToken post 请求中传递参数以获取 gem Oauth rails

ios - 想要了解如何直接从我的 iOS 应用程序发送电子邮件?山魈或邮件枪选项

html - 外壳脚本 : Send html formatted email while inside an array

ruby-on-rails - 冒号(:) gives load error in locale YAML file