Search code examples
emailemail-validation

Is it correct that sometimes I get angle brackets in "From" field of an e-mail message?


My software is working with incoming e-mail from the one and only particular sender (let it be [email protected]). According to RFC-2616 section 14 "From" header

MAY be used for logging purposes and as a means for identifying the source of invalid or unwanted requests.

That's exactly what I needed, so I wrote a code, which ignores all the messages where "From" field doesn't equal [email protected]. It worked good, but one day things changed, and now all the messages form Santa Claus contains a different string in "From" field (exactly <[email protected]>). I already fixed my code, but I just wonder, is this header legal? Because the same RFC-2616 section 14 says:

The address SHOULD be machine-usable, as defined by "mailbox" in RFC 822 [9] as updated by RFC 1123 [8]:

   From   = "From" ":" mailbox

An example is:

   From: [email protected]

Note the absense of angle brackets. But at the same time, many e-mail messages I receive on my Gmail account has something like this in the "From" field: "Santa Claus" <[email protected]>


Solution

  • RFC-822 allows email addresses to be specified either by a pure email-style address, called an "addr-spec" (e.g., [email protected]); or by using a nickname ("phrase") with the email-style address (the "addr-spec") enclosed in angle brackets (Foo Bar <[email protected]>). Your sender has gone from the first format to the second format, although here the nickname part seems to be empty.

    By the way, RFC-2616 is for HTTP; you're looking at the definition of an optional, and (I imagine) rarely-used, From: header in the HTTP protocol. That doesn't seem to have any direct relevance on email formats.