我设法发送了一封电子邮件,其中包含存储在 s3 上的 pdf 附件
def welcome_pack1(website_registration)
require 'open-uri'
@website_registration = website_registration
email_attachments = EmailAttachment.find(:all,:conditions=>{:goes_to_us=>true})
email_attachments.each do |a|
tempfile = File.new("#{Rails.root.to_s}/tmp/#{a.pdf_file_name}", "w")
tempfile << open(a.pdf.url)
tempfile.puts
attachments[a.pdf_file_name] = File.read("#{Rails.root.to_s}/tmp/#{a.pdf_file_name}")
end
mail(:to => website_registration.email, :subject => "Welcome")
end
附件附在电子邮件中。但它们以 0 字节的形式出现。我正在使用此处发布的示例回形针 + ActionMailer - 添加附件?. 我错过了什么吗?