Skip to content

Instantly share code, notes, and snippets.

@geocodinglife
Forked from Nosfheratu/my_mailer.rb
Created January 18, 2019 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geocodinglife/668ee96a3fe17eb55165bc4f4db5c48e to your computer and use it in GitHub Desktop.
Save geocodinglife/668ee96a3fe17eb55165bc4f4db5c48e to your computer and use it in GitHub Desktop.
send pdf attachment
class MyMailer < ApplicationMailer
def send_invoice user, invoice
@user = user
@invoice = invoice
invoice_attachment = WickedPdf.new.pdf_from_string(render_to_string(pdf: "invoice", template: 'payments/charges/invoice.pdf.erb'))
attachments["I#{sprintf('%06d', @invoice.id)}.pdf"] = invoice_attachment
mail(to: @user.email,
subject: "Your invoice", template_path: 'users_mailer')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment