What is the correct syntax for sending an email with actionmailer that includes some PDF file attachments? I am using Gmail for SMTP, with the TLS plugin. Here is what I have so far (and have tried variations on this too):
**lead_mailer.rb:**
def auto_response(lead)
recipients lead.email
subject "Information"
body :recipient => lead.first_name
from "[email protected]"
attachment "application/pdf" do |a|
a.body = File.read(RAILS_ROOT + "/public/files/Datasheet.pdf")
end
attachment "application/pdf" do |a|
a.body = File.read(RAILS_ROOT + "/public/files/OtherSheet.pdf")
end
end
**lead_observer.rb:**
class LeadObserver < ActiveRecord::Observer
def after_save(lead)
mail = LeadMailer.create_auto_response(lead)
LeadMailer.deliver(mail)
end
end
The problem is that it sends the attachments, but they show up as "no name", even though upon opening them they appear correctly. However, the body of the email does not appear at all. I am sure I am doing something simple, wrong.