我使用邮件投递服务(Sparkpost)发送电子邮件,每当有人回复这些邮件时,我都会收到一个包含以下内容的JSON:回复邮件正文的HTML格式(body_html)、回复邮件正文的纯文本格式(body_text)和回复消息的原始RFC822(email_rfc822)。
这种方法的问题在于它没有转发原始消息的附件。
如何更改此邮件程序以便从原始邮件中转发所有附件(包括在html正文中引用的内置图片)?
收到此JSON后,我需要将此电子邮件转发给另一个收件人。目前,我使用以下邮件程序来实现:
class ReplyMailer < ApplicationMailer
def reply(body_html, body_text, options = {})
mail(to: options[:to], from: options[:from], reply_to: options[:reply_to], subject: options[:subject], skip_premailer: true) do |format|
format.html { render html: body_html.html_safe } if body_html.present?
format.text { render plain: body_text } if body_text.present?
end
end
end
这种方法的问题在于它没有转发原始消息的附件。
如何更改此邮件程序以便从原始邮件中转发所有附件(包括在html正文中引用的内置图片)?