3
我有一個Ruby on Rails應用程序運行rails v2.3.5,它已經發送了很長一段時間的text/html郵件。最近我們注意到有些收件人收到的電子郵件是HTML代碼而不是HTML/ERB模板。儘管這並不是全面的,並且通常同一個電子郵件客戶端將同時接收HTML和HTML作爲文本,所以我不認爲它是客戶端電子郵件程序。爲什麼ActionMailer(rails 2.3.5)會間歇性地發送text/html郵件?
下面是一個擴展了ActionMailer :: Base的Notifier.rb的代碼片段。這一行動使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 <[email protected]>'
sent_on Time.now
content_type = "text/html"
headers = {}
end #end method customer_order_notification
服務器運行電子郵件軟件和配置的ActionMailer後綴低於:
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => '127.0.0.1',
:port => 25,
:domain => 'localhost'
}
也許某些客戶端的郵件客戶端只設置爲文本? – 2011-02-02 13:49:55