What is the email address format "Name <email>" called?
Given an email address in the format
John Doe <[email protected]>
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) -
[email protected]>
(address) -
John Doe <[email protected]>
-> what do you call the whole thing?
John Doe <[email protected]> → 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
It 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-list
Let'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 <[email protected]>
is aname-addr
, which is a variant ofmailbox
, which is a variant ofaddress
. -
John Doe
is adisplay-name
-
<[email protected]>
is anangle-addr
-
[email protected]
is anaddr-spec
-
john
is alocal-part
-
example.com
is adomain
.