【发布时间】:2012-07-13 19:57:44
【问题描述】:
我已成功发送一封电子邮件,其中包含存储在 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 字节的形式出现。我正在使用此处发布的示例paperclip + ActionMailer - Adding an attachment?。我错过了什么吗?
【问题讨论】:
标签: ruby-on-rails actionmailer email-attachments