开发者

Why would ActionMailer (rails 2.3.5) start sending text/html email intermittently?

I have a Ruby on Rails application running rails v2.3.5 which has been sending text/html ema开发者_StackOverflow社区il for quite some time. Recently we noticed that some recipients were receiving the emails as HTML code instead of the rendered HTML / ERB template. This is not across the board though, and often the same email client will receive both HTML and HTML as text so I don't think it's the client email program.

Here is a snippet from Notifier.rb which extends ActionMailer::Base. This action renders customer_order_notification.text.html.erb

def customer_order_notification(order)
  subject        "Thanks for your order!"
  body           :order => order
  recipients     RAILS_ENV == 'development' ? APP_CONFIG['dev_email'] : order.email
  bcc            RAILS_ENV == 'production' ? APP_CONFIG['supervisor_email'] : nil
  from           'MyWebsite <support@mywebsite.com>'
  sent_on        Time.now
  content_type   = "text/html"
  headers        = {}
end #end method customer_order_notification

The server is running postfix for email software and the ActionMailer config is below:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
  :address => '127.0.0.1',
  :port => 25,
  :domain => 'localhost'
}


I had a similar issue a while back, though it happened after upgrading from 2.3.5 to 2.3.8, but the fact that it's sending text messages to some clients rings enough of a bell for me to want to share:

https://github.com/mikel/tmail/issues/7

Regardless, it would be easy to check to see if your recipients are getting the double-line breaks in the To: field to rule it out. Are the clients with the issues using Outlook?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜