73

Given an email address in the format

John Doe <john@example.com>

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)
  • john@example.com> (address)
  • John Doe <john@example.com> -> what do you call the whole thing?
hippietrail
  • 4,605

3 Answers3

81

John Doe <john@example.com> → 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

DavidPostill
  • 162,382
51

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 <john@example.com> is a name-addr, which is a variant of mailbox, which is a variant of address.
  • John Doe is a display-name
  • <john@example.com> is an angle-addr
  • john@example.com is an addr-spec
  • john is a local-part
  • example.com is a domain.
0

allow me to necropost. i've digged up a bit regarding a concern "should a display-name (see rfc5322) with a dot (.) be enclosed in quotes?" mentioned in the prevoius answers/comments. it looks like:

  1. Section 3.2.3 indeed states that dot is not in the atext set, but in the specials set. So per that RFC a display-name with a dot must be en-quoted indeed.

  2. Nevertheless! Sections 4 and 4.1 talk about the "read-only" syntax and that dots are allowed in display-names without quotes for reading and parsing:

Though these syntactic forms MUST NOT be generated according to the grammar in section 3, they MUST be accepted and parsed by a conformant receiver. ... It appears here because the period character is currently used in many messages in the display-name portion of addresses, especially for initials in names, and therefore must be interpreted properly.

so wonderful.

vladis
  • 1