Given an email address in the format
John Doe <>I wonder where this format is explicitly defined and what the whole thing is called. It doesn't seem to be specified in rfc5322 (at least I didn't find it). So given the address above, what would you name the following member variables if you had to define a class for it?
John Doe(name)>(address)John Doe <>-> what do you call the whole thing?
2 Answers
John Doe <> → what do you call the whole thing?
It's called a mailbox, as specified in RFC 5322 on page 45:
3.4. Address Specification
Addresses occur in several message header fields to indicate senders and recipients of messages. An address may either be an individual mailbox, or a group of mailboxes.
Normally, a mailbox is composed of two parts: (1) an optional display name that indicates the name of the recipient (which can be a person or a system) that could be displayed to the user of a mail application, and (2) an addr-spec address enclosed in angle brackets ("<" and ">"). There is an alternate simple form of a mailbox where the addr-spec address appears alone, without the recipient's name or the angle brackets. The Internet addr-spec address is described in section 3.4.1.
Source 3.4. Address Specification
See also Appendix A.1.2. Different Types of Mailboxes
8It is in the RFC5322, you just missed it:
address = mailbox / group
mailbox = name-addr / addr-spec
name-addr = [display-name] angle-addr
angle-addr = [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr
group = display-name ":" [group-list] ";" [CFWS]
display-name = phrase
mailbox-list = (mailbox *("," mailbox)) / obs-mbox-list
address-list = (address *("," address)) / obs-addr-list
group-list = mailbox-list / CFWS / obs-group-listLet's break this down.
address either a mailbox or a group. A mailbox is a name-addr or addr-spec.
This name-addr is the format you're asking about: there is an optional display-name (it's optional because it is defined with square brackets) followed by the angle-addr, which itself is an addr-spec in angle brackets with optional foldable space CFWS on both sides of it (defined further in the section 3.2.2), or an obsolete address format obs-angle-addr.
A whole section 3.4.1 is dedicated to the description of addr-spec format.
So, in conclusion:
John Doe <>is aname-addr, which is a variant ofmailbox, which is a variant ofaddress.John Doeis adisplay-name<>is anangle-addr- is an
addr-spec johnis alocal-partexample.comis adomain.