Hostingrails 的 sendmail_setting
下午好,
我遇到了一个关于如何通过 Hostingrails 上托管的应用程序发送电子邮件的问题。
在我的配置/初始化程序中,我添加了一个包含此文件的“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 [email protected]'
}
end
,我的邮件程序如下所示
: ActionMailer::Base
def subscription_confirmation(user)
setup_email(user)
mail(:to => @recipients, :subject => "blabla")
end
protected
def setup_email(user)
@recipients = user.email
@from = "[email protected]"
headers "Reply-to" => "[email protected]"
@sent_on = Time.now
@content_type = "text/html"
end
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 的想法或配置文件。
谢谢你, 阿尔班迪格尔
Good afternoon,
I'm facing a problem about the way to send email through my application hosted on hostingrails.
In my config/initializers I added a file "setup_mailer" containing this
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 [email protected]'
}
end
and my mailer is as below
class Notification < ActionMailer::Base
def subscription_confirmation(user)
setup_email(user)
mail(:to => @recipients, :subject => "blabla")
end
protected
def setup_email(user)
@recipients = user.email
@from = "[email protected]"
headers "Reply-to" => "[email protected]"
@sent_on = Time.now
@content_type = "text/html"
end
end
It seems to work very fine on my local machine. But in production, emails are not sent properly and I receive this message in my support inbox.
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.
If you have any idea, the support seems cannot help me, hope some of you'll have ideas or config files from hostingrails to share.
Thank you,
albandiguer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了完全相同的问题 - 通过从 sendmail_settings 中删除 -t 解决了它。
我没有进一步研究其他影响,但至少它是有效的。但从手册页来看:
那么也许只是 Postfix 版本的差异?
I had exactly the same problem - resolved it by removing the -t from the sendmail_settings.
I haven't looked much further to investigate other implications, but at least it works. But from the man page:
So maybe just a difference in Postfix versions?
尝试在 user.email 上调用 to_s 或将用户电子邮件指定为“#{user.email}”
Try calling to_s on user.email or specifying user email as "#{user.email}"