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

狂风中的少年 提交于 2020-07-05 03:08:56

问题


My software is working with incoming e-mail from the one and only particular sender (let it be SantaClaus@hetnet.nl). 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 SantaClaus@hetnet.nl. It worked good, but one day things changed, and now all the messages form Santa Claus contains a different string in "From" field (exactly <SantaClaus@hetnet.nl>). 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: webmaster@w3.org

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" <santaclaus@hetnet.nl>


回答1:


RFC-822 allows email addresses to be specified either by a pure email-style address, called an "addr-spec" (e.g., name@host.domain); or by using a nickname ("phrase") with the email-style address (the "addr-spec") enclosed in angle brackets (Foo Bar <foobar@host.domain>). 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.



来源:https://stackoverflow.com/questions/4473804/is-it-correct-that-sometimes-i-get-angle-brackets-in-from-field-of-an-e-mail-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!