I'm trying to send emails that have both a plain text and html component. There are no attachments, but there are inline images in the HTML part. I'm using the content-type "multipart/alternative". I'm not explicitly setting the parts; I'm relying on the filenames to determine the parts. I'm on rails 2.3.10.
Approximately 60% of the time, the emails that are sent come through with no body, and the HTML part is attached to the message with the name "noname" (in gmail anyway). The rest of the time they send as expected. If I send out 10 emails in 10 seconds, almost always 6 of them will be blank.
When I inspect the logs, the messages that come through correctly show both mime parts in the log and show a boundary value in the content-type declaration.
The blank emails still have a content-type of multipart/alternative, but no boundary, because the blank emails do not render the plain text part, and only show the html part. Looking at the templates being rendered, it's clear that the plain text part of the message is completely skipped.
Why does this sometimes work and often fail? The messages are all being sent with a delayed job.
Log for a "good" email:
Rendered notifications/_comment (0.1ms)
Rendered layouts/_footer (2.1ms)
Rendered layouts/_container (2.3ms)
Rendered shared/attachments/_count (0.6ms)
Rendered layouts/speech/_bubble (21.4ms)
Rendered layouts/speech/_detail (0.8ms)
Rendered notifications/_comment (22.6ms)
Rendered layouts/_footer (2.0ms)
Rendered layouts/_container (2.2ms)
Sent mail to [redacted]Date: Mon, 8 Nov 2010 11:37:24 -0800
From: "[redacted]" <[redacted]>
Reply-To: "[redacted]" [redacted]
To: [redacted]
Subject: Someone commented on your thing
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=mimepart_4cd85174328d6_1486..fdbe5b8d87fe--mimepart_4cd85174328d6_1486..fdbe5b8d87fe
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline[the content of the plain text part]
[the content of the html part]
--mimepart_4cd85174328d6_1486..fdbe5b8d87fe--
Log for the blank email:
Rendered shared/attachments/_count (0.1ms)
Rendered layouts/speech/_bubble (0.6ms)
Rendered layouts/speech/_detail (0.7ms)
Rendered notifications/_comment (1.6ms)
Rendered layouts/_footer (25.9ms)
Rendered layouts/_container (26.1ms)
Sent mail to [redacted]Date: Mon, 8 Nov 2010 11:37:29 -0800
From: "[redacted]" <[redacted]>
Reply-To: "[redacted]" <[redacted]>
To: [redacted]
Subject: Someone commented on your thing
Mime-Version: 1.0
Content-Type: multipart/alternative; charset=utf-8[the content of the HTML part]
Note that those emails were sent 5 seconds apart, and both emails (were supposed to) contain the same thing.