我正在使用以下代码发送带有 pdf 附件的电子邮件:
class StudyMailer < ActionMailer::Base
def notify_office(study, sent_at = Time.now)
subject "Email Subject Goes Here"
recipients 'user@domain.come'
from "#{study.sender.full_name} <#{study.sender.email}>"
sent_on sent_at
body :study => study
for document in study.documents
attachment :content_type => "application/pdf", :body => File.read(document.document.path) #absolute path to .pdf document
end
end
end
发送电子邮件时,附件似乎以二进制代码而不是 .pdf 附件的形式呈现。
如何将 .pdf 呈现为典型附件,而不是内联?