Hostingrails 的 sendmail_setting

发布于 2024-11-09 02:53:26 字数 1716 浏览 0 评论 0原文

下午好,

我遇到了一个关于如何通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心欲静而疯不止 2024-11-16 02:53:26

我遇到了完全相同的问题 - 通过从 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.

那么也许只是 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:

   -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.

So maybe just a difference in Postfix versions?

禾厶谷欠 2024-11-16 02:53:26

尝试在 user.email 上调用 to_s 或将用户电子邮件指定为“#{user.email}”

Try calling to_s on user.email or specifying user email as "#{user.email}"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文