下午好,
我面临着通过托管在托管轨道上的应用程序发送电子邮件的方式的问题。
在我的配置/初始值设定项中,我添加了一个包含此的文件"setup_mailer"
ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.default_charset = "utf-8"
# Production
if Rails.env.production?
ActionMailer::Base.sendmail_settings = {
:location => '/usr/sbin/sendmail',
:arguments => '-i -t -f support@xxxxx.xxx'
}
end
我的邮件如下
类通知 <操作邮件::基础>
def subscription_confirmation(user)
setup_email(user)
mail(:to => @recipients, :subject => "blabla")
end
protected
def setup_email(user)
@recipients = user.email
@from = "support@xxxxx.xx"
headers "Reply-to" => "support@xxxxx.xx"
@sent_on = Time.now
@content_type = "text/html"
end
结束
它似乎在我的本地机器上工作得很好。但在生产中,电子邮件无法正确发送,我在支持收件箱中收到此消息。
A message that you sent using the -t command line option contained no
addresses that were not also on the command line, and were therefore
suppressed. This left no recipient addresses, and so no delivery could
be attempted.
如果您有任何想法,支持似乎无法帮助我,希望你们中的一些人会从 hostingrails 获得想法或配置文件来分享。
谢谢阿尔班迪格尔
我遇到了完全相同的问题 - 通过从sendmail_settings中删除 -t 来解决它。
我没有进一步研究其他影响,但至少它是有效的。但从手册页:
-t Extract recipients from message headers. These are added to any
recipients specified on the command line.
With Postfix versions prior to 2.1, this option requires that no
recipient addresses are specified on the command line.
所以也许只是后缀版本的差异?
尝试在 user.email 上调用to_s或将用户电子邮件指定为"#{user.email}"