开发者

Converting old Mailer to Rails 3 (multipart/mixed)

开发者 https://www.devze.com 2023-02-02 03:44 出处:网络
I\'m having some difficulties converting this old mailer api to rails 3: content_type\"multipart/mixed\"

I'm having some difficulties converting this old mailer api to rails 3:

content_type "multipart/mixed"

part :content_type => "multipart/alternative" do |alt|

  alt.part "text/plain" do |p|
     p.body = render_message("summary_report.text.plain.erb",

:message => message.gsub(/<.br.>/,"\n"), :campaign=>campaign, :aggregate=>aggregate, :promo_messages=>campaign.participating_promo_msgs) end

   alt.part "text/html" do |p|
      p.body = render_message("summary_report.text.html.erb",

:message => message, :campaign=>campaign, :aggregate=>aggregate,:promo_messages=>campaign.participating_promo_msgs) end

end
if bounce_path
  attachment :content_type => "text/csv",
  :body=> File.read(bounce_path),
  :filename => "rmo_bounced_emails.csv"
end
attachment :content_type => "application/pdf",
      :body => File.read(report_path),
      :filename=>"rmo_report.pdf"

In particular I don't understand how to differentiate the different multipart options. Any idea开发者_JS百科?


"Action Mailer will automatically send multipart emails if you have different templates for the same action." For example having these files would give you text and html versions:

summary_report.text.erb
summary_report.html.erb

Check the Rails Guides for details:

  • http://guides.rubyonrails.org/action_mailer_basics.html#sending-multipart-emails
  • http://guides.rubyonrails.org/action_mailer_basics.html#sending-emails-with-attachments
0

精彩评论

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

关注公众号