Tag: html email

如何在发送之前修改actionmailer email html_part

我已经掌握了即将发送电子邮件的所有内容,但我需要修改所有链接以包含Google Analytics属性。 问题是,如果我尝试读取/写入电子邮件的html_part.body,整个html字符串会以某种方式编码并且不能正确显示电子邮件(即变为<html> )。 我在记录器中记录了html_part.body.raw_source并显示为正确的未编码HTML,只有在实际发送电子邮件时才会发生编码。 EBlast.rb(ActionMailer) def main(m, args={}) # Parse content attachment references (they don’t use helpers like the layout does) # and modify HTML in other ways m.prep_for_email self @email = m # Needed for helper methods in view mail_args = { :to => @user.email, :subject => m.subject, :template_path => ‘e_blast’, :template_name => […]

使用Rails 3的电子邮件中的CSS图像

我正在尝试发送一封包含Rails 3和Action Mailer的电子邮件。 电子邮件很好,但我希望它是HTML格式的一些基本样式,包括背景图像。 我知道图像可能会被阻止,直到用户允许它们显示,但我仍然认为最好链接到我的Web服务器上的图像。 名为registration_confirmation.html.erb的电子邮件模板如下所示: Untitled Document body { background: url(/images/mainbg_repeat.jpg) top repeat-x #cfcfcf; margin: 0px 0px 0px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #565656; } 获取背景图像的url链接以包含完整主机以使背景显示在电子邮件中的最佳方法是什么?

在iphone中无法正确呈现内嵌图像的html电子邮件

我希望有人可以帮助我解决我在下面的代码中出错的问题 – 我的电子邮件被发送,图像在大多数电子邮件客户端(gmail web,android)中正确内联,但它在iphone上无法正常呈现ipad:仅显示最后附加的图片,不显示任何html内容或文本内容。 我理解每个电子邮件客户端解释和呈现不同的有效负载,我不知道如何使它在iPhone上工作。 任何帮助赞赏! ruby代码: require ‘mail’ def inline_body_with_attachments(html, attachments) attachments.each do |attachment| if (html =~ /#{attachment.filename}/) html = html.sub(attachment.filename, “cid:#{attachment.cid}”) end end return html end mail = Mail.new({ :from => “foo@bar.com”, :to => “you@gmail.com”, :subject => “html email with inline images” }) text_part = Mail::Part.new do body “some text” end mail.text_part = […]