开发者

sendmail_setting for 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 support@xxxxx.xxx'
    }
end

and my mailer is as below

class Notification < ActionMailer::Base

def subscription_confirmation(user)
    setup_email(user开发者_JS百科)
    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

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


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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜