40

Are email headers case sensitive?

For example, is Content-Type different from Content-type?

According to RFC 5322, I don't see anything about case sensitivity. However, I'm seeing a problem with creating MIME messages using the PEAR Mail_mime module, and everything is pointing to the fact that our SMTP server uses Content-type and MIME-version instead of Content-Type and MIME-Version. I tried using another SMTP server (like GMail), but unfortunately our web servers are firewalled pretty tightly.

Community
  • 1
  • 1
Michael Irigoyen
  • 22,513
  • 17
  • 89
  • 131
  • 2
    The answer depends on what you're doing; it's not just a matter of 'the rules' that apply equally in all situations. Postel’s Robustness Principle from the early days of the Internet is still an excellent guide: “Be conservative in what you do, be liberal in what you accept from others”. So if you're receiving emails or parsing email headers, then 'no' they are not case sensitive - but if you're sending emails or tweaking email headers, then 'yes' they are case sensitive. -- Also note that for very old standards (email was first specified by RFC 822 in 1982), common usage trumps 'the rules'. – Chuck Kollars Aug 21 '14 at 19:30

1 Answers1

69

RFC 5322 does actually specify this, but it is very indirect.

Section 1.2.2 says:

This specification uses the Augmented Backus-Naur Form (ABNF) [RFC5234] notation for the formal definitions of the syntax of messages.

In turn, Section 2.3 of RFC 5234 says:

NOTE:

ABNF strings are case insensitive and the character set for these strings is US-ASCII.

So when RFC 5322 specifies a production rule like this:

from = "From:" mailbox-list CRLF

It is implicit that the "From:" is not case-sensitive.

[update]

As for Content-Type and MIME-Version, they are specified by the MIME spec (RFC 2045). That in turn refers to the BNF described by the original RFC 822, which (luckily) also makes it clear that these literal strings are case-insensitive.

Bottom line: According to the spec, Email headers are not case-sensitive, so it sounds like your mail server is buggy.

Community
  • 1
  • 1
Nemo
  • 70,042
  • 10
  • 116
  • 153
  • 1
    Thanks for the detailed answer. It definitely helped. As a side note, doing more testing, we've determined it's Thunderbird that was the issue. Every other mail client respected the alternative text properly, but Thunderbird chokes. – Michael Irigoyen May 26 '11 at 19:54