This project is archived and is in readonly mode.

#6283 new
bhushan

Pdf attachment not working rails 3.0.3

Reported by bhushan | January 12th, 2011 @ 02:37 PM

In rails 3 when we attach pdf document in email through action mailer,
that pdf is not come as a attachment in e-mail, its come in body like

Date: Wed, 29 Dec 2010 19:56:12 +0530
Mime-Version: 1.0
Content-Type: application/pdf;
charset=UTF-8;
filename=free_book.pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename=free_book.pdf
Content-ID: 4d1b450431abc_e3c211babc122f@xxxxxxxxxxxxx

JVBERi0xLjMKJf////8KMSAwIG9iago8PCAvQ3JlYXRvciAoUHJhd24pCi9Q
cm9kdWNlciAoUHJhd24pCj4+CmVuZG9iagoyIDAgb2JqCjw8IC9UeXBlIC9Q
YWdlcwovQ291bnQgMQovS2lkcyBbNSAwIFJdCj4+CmVuZG9iagozIDAgb2Jq
Cjw8IC9UeXBlIC9DYXRhbG9nCi9QYWdlcyAyIDAgUgo+PgplbmRvYmoKNCAw
IG9iago8PCAvTGVuZ3RoIDU4OAo+PgpzdHJlYW0KL0RldmljZVJHQiBjcwow
LjAwMCAwLjAwMCAwLjAwMCBzY24KL0RldmljZVJHQiBDUwowLjAwMCAwLjAw
MCAwLjAwMCBTQ04KcQoKQlQKNDEgNzQzLjUwNCBUZAovRjEuMCA4IFRmCls8
NGY3MjY0NjU3Mj5dIFRKCkVUCgoKQlQKNDEgNzM0LjI1NiBUZAovRjEuMCA4
IFRmCls8NTM3NTZkNmQ2MTcyPiAtMzAgPDc5Pl0gVEoKRVQKCjAuMDAwIDAu
MDAwIDAuMDAwIHNjbgoKQlQKMTA4IDc0My41MDQgVGQKL0YxLjAgOCBUZgpb
PDQyNjE3NDYzNjgyMDQ0NjE3NDY1MmY1NDY5NmQ2NTNhNTc+IDMwIDw2NTY0
MjA0NDY1NjMyMDMyMzkyMDMxMzkzYTM1MzYzYTMxMzEyMDJiMzAzNTMzMzAy
MDMyMzAzMTMwPl0gVEoKRVQKCjAuMDAwIDAuMDAwIDAuMDAwIHNjbgoKQlQK
MzAyIDc0My41MDQgVGQKL0YxLjAgOCBUZgpbPDRmNzI2NDY1NzIyMDYyNjE3
NDYzNjgyMDZlNmYzYTMxMzgzMjMxMzEzNTM5Mzk+XSBUSgpFVAoKMC4wMDAg
MC4wMDAgMC4wMDAgc2NuCgpCVAoyNDIuMTQ4IDY5OC44ODggVGQKL0YxLjAg
MTIgVGYKWzw1MDcyNmY2NDc1NjM3NDIwNmM2OTczNzQyMDY5NzMyMDZlNmY3
NDIwNjY+IDMwIDw2Zjc1NmU2NDJlPl0gVEoKRVQKClEKCmVuZHN0cmVhbQpl
bmRvYmoKNSAwIG9iago8PCAvVHlwZSAvUGFnZQovUGFyZW50IDIgMCBSCi9S
ZXNvdXJjZXMgPDwgL1Byb2NTZXQgWy9QREYgL1RleHQgL0ltYWdlQiAvSW1h
Z2VDIC9JbWFnZUldCi9Gb250IDw8IC9GMS4wIDYgMCBSCj4+Cj4+Ci9NZWRp
YUJveCBbMCAwIDYxMi4wIDc5Mi4wXQovQ29udGVudHMgNCAwIFIKPj4KZW5k
b2JqCjYgMCBvYmoKPDwgL0VuY29kaW5nIC9XaW5BbnNpRW5jb2RpbmcKL1R5
cGUgL0ZvbnQKL0Jhc2VGb250IC9IZWx2ZXRpY2EKL1N1YnR5cGUgL1R5cGUx
Cj4+CmVuZG9iagp4cmVmCjAgNwowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAw
MDAwMTUgMDAwMDAgbiAKMDAwMDAwMDA3MSAwMDAwMCBuIAowMDAwMDAwMTI4
IDAwMDAwIG4gCjAwMDAwMDAxNzcgMDAwMDAgbiAKMDAwMDAwMDgxNiAwMDAw
MCBuIAowMDAwMDAwOTk0IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1Jvb3QgMyAw
IFIKL0luZm8gMSAwIFIKL1NpemUgNwo+PgpzdGFydHhyZWYKMTA5MQolJUVP
Rgo=


I read whole document of rails3 action mailer and i copied same code
which is mention in action mailer docs, stil its not working. can any
one give me some idea so that code can work. i am using ruby 1.8.7 and rails 3.0.3

my code is

require 'rubygems'
class OrderMailer < ActionMailer::Base
default :from => 'bhushan.fegade@arrkgroup.com'

def email_orders

OrderMailer.pdf_email.deliver

end

def pdf_email

attachments['terms.pdf'] = File.read('C:\\Bhushan\\hello.pdf')
mail(:to => "bhushan.fegade@arrkgroup.com",
     :subject => "Please see the Terms and Conditions attached")

end

end

Comments and changes to this ticket

  • Dan Pickett

    Dan Pickett March 12th, 2011 @ 03:27 PM

    do you have a correlating view for that pdf_email method? If there is no text or html template it looks like it might render the attachments inline. The view (or the text in the mail block) could be blank if you just want to send the attachment without any other messaging.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages