I've got a mailer that as follows:
class Payments::LateNoticesMailer < AsyncMailer
def notice(payment_id)
@payment = PaymentDecorator.find(payment_id)
@invoice = @payment.invoice
template = "payments/invoices/#{@payment.made_with_type.downcase}/show"
attachments["#{@payment.invoice_filename}.pdf"] =
WickedPdf.new.pdf_from_string( render_to_string( pdf: @payment.invoice_filename,
formats: [:pdf],
template: template,
layout: "layouts/pdf.html"))
mail to: @payment.payer_email,
from: '"RentingSmart" <[email protected]>',
cc: @payment.landlord_email,
subject: "*** Your rent payment of #{@payment.amount_due} is overdue ***"
end
end
which I send using SendGrid. Here's my issue, if I open up the email via Gmail, everything works great, the text of the email is there, and the attachment is attached. However, if I open it up using OSX's Mail.app or on my iPhone, I simply get the following:
This is a multi-part message in MIME format...
Anybody have any tips? I think I am following the Rails guides correctly.
Here is the call that I make Payments::LateNoticesMailer.notice(payment.id).deliver
pdf: "#{@payment.invoice_filename}.pdf"
instead ofpdf: @payment.invoice_filename
(i.e. you're missing the.pdf
when you render). – Claymore