Attachment issue


I generated the pdf file with image header (jpg log is displayed on top
of the pdf file). I can see the logo and the datas in the pdf file
generated. Fine. I tried to send the generated pdf in the email (using
action mailer). Iam getting the pdf file in the email, but when I open
the pdf file, the acrobat reader is not able to open the file.

The problem here is the action mailer is not sending the pdf file
properly if the pdf has image inside.

This is the code:

attachment "application/pdf" do |a|
        a.body =
        puts "FIle name"
        puts File.basename(email_attachment)

Any idea to fix the issue?

Fixed the issue

email_attachment = "#{RAILS_ROOT}/public/#{file_name}"

      attachment "application/pdf" do |a|
        file =, "r+b")
        a.body =