...or, in other words: When sending a mail programmatically, do I really need to go through the hassle of setting the correct MIME type or can I just use application/octet-stream?

The mail clients I tested all do "the right thing" based on the file extension, even if the MIME type is just the generic application/octet-stream, so why bother?

I know that it is considered "good practice". I'm asking out of scientific curiosity, because I want to know if it makes a practical difference or not.

  • 1
    That totally depends on the client. – Oded Apr 14 '13 at 18:50
  • How do you know the recipient is using Windows? – grahamparks Apr 14 '13 at 20:24
  • @Oded: Exactly, and that's the whole point of the question: Is there a Windows mail client out there in the wild that actually needs the correct MIME type? – Heinzi Apr 15 '13 at 6:03
  • 1
    @Heinzi - Pegasus Mail takes its mime types very seriously. – Oded Apr 15 '13 at 7:41

The robustness principle suggests that should send as correct of data as you can. The mail clients are also following it by accepting things that are not always properly formatted. That isn't an excuse not to format your data correctly.

This is most famously described in RFC 791 which defines the IP in TCP/IP.

In general, an implementation must be conservative in its sending behavior, and liberal in its receiving behavior

RFC 1122 (Requirements for Internet Hosts -- Communication Layers) further clarifies this in section 1.2.2.

RFC 3117 (On the Design of Application Protocols) describes some issues when programmers don't follow a robust protocol practice. It concludes with:

Accordingly, explicit consistency checks in a protocol are very useful, even if they impose implementation overhead.

Write your code following the standard as closely as possible. Don't take shortcuts because they work on the implementations you have tested on, because someday you will find an implementation that it doesn't work on.

  • Thanks, that's a valid point. I'll leave the question open for now, though, since I'm still curious whether there actually is "an implementation that it doesn't work on". – Heinzi Apr 15 '13 at 6:02
  • @Heinzi One could go through and test all of the email clients listed on Wikipedia... and then you get things like mutt on windows compiled back in 2001... – user40980 Apr 15 '13 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.