How do I email a PDF generated using PDFKit and on Heroku in Rails?
I am using PDFKit on Heroku (and also locally for dev) and am having difficulty emailing the generating PDF from my cron task.
This is the code in my cron job:
kit = PDFKit.new(html_file)
file = kit.to_pdf
OutboundMailer.deliver_pdf_email(file)
#kit.render_file("pdf_from_cron.pdf")
This is the code in my Mailer:
def pdf_email(pdf)
subject "This is your batch of letters"
recipients "helloworld@gmail.com"
from "B开发者_开发知识库atch Email <hello@batch.com>"
sent_on Date.today
body "This is the body of pdf"
attachment "application/pdf" do |a|
a.filename = "batch-letters.pdf"
a.body = pdf
end
end
I setup PDFKit on Heroku once and followed: http://blog.mattgornick.com/using-pdfkit-on-heroku. You may need to include the binary.
精彩评论