marnanel: (Default)
Monument ([personal profile] marnanel) wrote2014-10-04 10:39 pm

multipart

Today I received an email from someone who said they'd attached a file I needed, but I couldn't see the attachment. After some digging, I found that the message was structured like this:

multipart/alternative: (i.e. "these are alternative versions of the same thing")
-- text/plain (a version of the message in plain text)
-- multipart/related: (i.e. "these parts belong together")
-- -- text/html (a version of the message in HTML)
-- -- the attachment

So if your email program shows HTML for preference, you would see the attachment, but if it shows plain text for preference (as mine does), you wouldn't. Of course it *should* have been structured like this:

multipart/related: (i.e. "these parts belong together")
-- multipart/alternative: (i.e. "these are alternative versions of the same thing")
-- -- text/plain (a version of the message in plain text)
-- -- text/html (a version of the message in HTML)
-- the attachment

[personal profile] treeowl 2014-10-05 03:40 am (UTC)(link)
Oooops.
simont: A picture of me in 2016 (Default)

[personal profile] simont 2014-10-05 06:56 am (UTC)(link)
I summarised this out loud to a few friends last night, in gobsmacked disbelief, and one of them pointed out that the first structure would actually have made perfect sense if the attachment had been something that really did belong to the HTML part specifically – e.g. a stylesheet, or a purely presentational image.

That cured me of my gobsmacked disbelief – at least now the sending MUA only got the wrong one of two MIME structures with sensible purposes, rather than inventing something so weird it could not possibly have been useful for anything :-)
simont: A picture of me in 2016 (Default)

[personal profile] simont 2014-10-06 10:05 am (UTC)(link)
And, coincidentally, this morning I received an email with the same issue. In this case the attachments are images referred to from the HTML part by "cid:..." type URIs – but they're not letterheads and logos and backgrounds and purely presentational stuff, they're screenshots that are part of the bug report contained in the email, so they ought to have been MIME-structured as not specific to the HTML part. Unfortunately, the MUA would probably have had to be AI-complete to tell the difference between the two cases :-/