我想用 ActionMailer 发送电子邮件。我想以 ISO-8859-1 和 UTF-8 发送相同的 csv 编码
我的邮递员:
class MyMailer < ActionMailer::Base
default :from => "Me <contact@me.com>"
# ===========
# = Reports =
# ===========
# report is in UTF-8
def send_report(email, report, subject, filename, campaign_id)
attachments[filename + '.utf_8.csv']= { :data => report, :encoding => 'base64', :mime_type => "text/csv" }
attachments[filename + '.latin1.csv']= { :data => report.encode('ISO-8859-1'), :encoding => 'base64', :mime_type => "text/csv; charset=ISO-8859-1" }
@campaign_id = campaign_id
mail(to: email, subject: subject)
end
end
我得到了错误:
incompatible character encodings: ISO-8859-1 and UTF-8
如果我尝试单独发送它们中的每一个,它工作正常......