Leave a comment

Sending generated PDF attachments mail in Rails

There are many gems which are used for generating PDF such as “prawn”,”wicked_pdf” and “pdf-kit”

but here i show you how we can generate pdf attachement mail using wicked_pdf.

mail(:subject => ‘Your Subject’, :to => email, :from => sender_email)  do |format|
format.pdf do
attachments[“attachement_name.pdf”] = WickedPdf.new.pdf_from_string(
render_to_string(:pdf => “receipt”, :template => ‘mailer_view/mailer_action.pdf.erb’)
by this we can generate an email which render html view as well as send pdf attachment to the recepient user.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: