【发布时间】:2017-02-25 22:51:04
【问题描述】:
我已阅读完整的官方指南 here 以及关于 SO 的大约 5 个问题,这些问题描述了 Rails 3 和 Rails 4 的这个问题。
This question 用于 Rails 5,但他使用的是实际文件,而不是编码字符串。
这是我的邮件代码(是的,我设置了两个视图)。这封电子邮件非常顺利,附有 PDF。
def pdf_quote(proposal)
@proposal = proposal
email_with_name = %("#{@proposal.first_name} #{@proposal.last_name}" <#{@proposal.email}>)
filename = "QD-#{@proposal.qd_number}_#{@proposal.last_name}.pdf"
attachments[filename] = {
mime_type: 'application/pdf',
encoding: 'Base64',
content: @proposal.pdf_base64
}
mail(
to: email_with_name,
from: 'Floorbook UK <email address>',
subject: 'Your Personal Flooring Quote is attached',
sent_on: Time.now
)
end
在 gmail 中,附件称为“noname”,在邮箱中称为“pb_mime_attachment.pdf”
如何让 ActionMailer 使用我提供的文件名?
请注意,我正在使用 MailGun (mailgun-ruby gem 1.1.4) 发送电子邮件,所以这里可能是 gem 的问题。
【问题讨论】:
标签: ruby-on-rails actionmailer