ERS, 每当我的应用程序发送纯文本电子邮件通知人们各种事情时,某些电子邮件客户端将电子邮件解释或接收为两封不同的电子邮件。它适用于gmail和comcast。通过通用主机(如Web主机附带的主机)收到电子邮件的用户会收到两封相同纯文本电子邮件的电子邮件。这非常烦人。我很感激任何见解。直到修好我才能发射。请赐予你强大的智慧!我喜欢这个网站!
配置/初始化/为setup_mail.rb
ActionMailer::Base.default_content_type = "text/plain"
配置/环境/ production.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "mail.xxxessment.com",
:port => 26,
:domain => "www.xxxessment.com",
:user_name => "systemadmin+xxxessment.com",
:password => "secret",
:authentication => "plain",
:enable_starttls_auto => false
}
模型/ actionitem_observer.rb
def after_save(actionitem)
if actionitem.responsible_id_changed? and !actionitem.responsible_id.nil?
Notifier.deliver_responsible_alert(actionitem, actionitem.responsible.email)
end
end
寄件人/ notifier.rb
def responsible_alert(actionitem,responsible_email)
subject "New action item assignment from xxxxx Assessment"
from "systemadmin@xxxxxsessment.com"
recipients responsible_email
sent_on Time.zone.now
content_type "text/plain"
body :actionitem => actionitem
end
视图/通知/ responsible_alert.text.erb
You have been assigned Action Item #<%= @actionitem.id %> in the xxxessment system.
Action Item: <%= @actionitem.name %>
Please login in and look at the My Action Items tab to find the new item.
Thank you.
答案 0 :(得分:0)
这里的问题是语法的旧版本。我想这不是rails在Notifier.rb中编写代码的方式,而且效果很好。
def responsible_alert(actionitem,responsible_email)
@actionitem = actionitem
@responsible_email = responsible_email
mail(:to => @responsible_email, :subject => "New action item assignment from SXXXXXssessment") do |format|
format.html
format.text
end
end