Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29922

Problem sending multipart mail using ActionMailer

$
0
0

I'm using the following code to send emails in rails:

class InvoiceMailer < ActionMailer::Base  def invoice(invoice)    from          CONFIG[:email]    recipients    invoice.email    subject       "Bevestiging Inschrijving #{invoice.course.name}"    content_type  "multipart/alternative"    part "text/html" do |p|      p.body = render_message 'invoice_html', :invoice => invoice    end    part "text/plain" do |p|      p.body = render_message 'invoice_plain', :invoice => invoice    end    pdf = Prawn::Document.new(:page_size => 'A4')    PDFRenderer.render_invoice(pdf, invoice)    attachment :content_type => "application/pdf", :body => pdf.render, :filename => "factuur.pdf"    invoice.course.course_files.each do |file|      attachment :content_type => file.content_type, :body => File.read(file.full_path), :filename => file.filename    end  endend

It seems fine to me, and the emails also show up like they should in the Gmail web-interface. In Mail (the Apple program), however, I get just 1 attachment (where there should be 2) and there is no text. I just can't seem to figure out what's causing it.

I copied the email from the logs:

Sent mail to xxx@gmail.comFrom: yyy@gmail.comTo: xxx@gmail.comSubject: Bevestiging Inschrijving Authentiek SprekenMime-Version: 1.0Content-Type: multipart/alternative; boundary=mimepart_4a5b035ea0d4_769515bbca0ce9b412a--mimepart_4a5b035ea0d4_769515bbca0ce9b412aContent-Type: text/html; charset=utf-8Content-Transfer-Encoding: Quoted-printableContent-Disposition: inline

Dear sir

=--mimepart_4a5b035ea0d4_769515bbca0ce9b412aContent-Type: text/plain; charset=utf-8Content-Transfer-Encoding: Quoted-printableContent-Disposition: inlineDear sir* Foo=--mimepart_4a5b035ea0d4_769515bbca0ce9b412aContent-Type: application/pdf; name=factuur.pdfContent-Transfer-Encoding: Base64Content-Disposition: attachment; filename=factuur.pdfJVBERi0xLjMK/////woxIDAgb2JqCjw8IC9DcmVhdG9yIChQcmF3bikKL1Byb2R1Y2VyIChQcmF3bikKPj4KZW5kb2JqCjIgMCBvYmoKPDwgL0NvdW50IDEK... ... ...MCBuIAp0cmFpbGVyCjw8IC9JbmZvIDEgMCBSCi9TaXplIDExCi9Sb290IDMgMCBSCj4+CnN0YXJ0eHJlZgo4Nzc1CiUlRU9GCg==--mimepart_4a5b035ea0d4_769515bbca0ce9b412aContent-Type: application/pdf; name=Spelregels.pdfContent-Transfer-Encoding: Base64Content-Disposition: attachment; filename=Spelregels.pdfJVBERi0xLjQNJeLjz9MNCjYgMCBvYmoNPDwvTGluZWFyaXplZCAxL0wgMjExNjYvTyA4L0UgMTY5NTIvTiAxL1QgMjEwMDAvSCBbIDg3NiAxOTJdPj4NZW5k... ... ...MDIwNzQ4IDAwMDAwIG4NCnRyYWlsZXINCjw8L1NpemUgNj4+DQpzdGFydHhyZWYNCjExNg0KJSVFT0YNCg==--mimepart_4a5b035ea0d4_769515bbca0ce9b412a--

Viewing all articles
Browse latest Browse all 29922

Trending Articles