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?

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

  • 6
    – Era
    Feb 13 '21 at 10:01
  • I think the name must be in quotes: "John Doe" <john@example.com>
    – i486
    Feb 15 '21 at 7:31
  • 2
    @i486 Quotes are not required. See the examples in the RFC (second link in my answer).
    – DavidPostill
    Feb 15 '21 at 8:13
  • 1
    @i486 Quotes are only required if the name contains non-atom characters (with . special cased). E.g. a , makes quotes neccessary. See 3.2.5 and 4.1.
    – cg909
    Feb 15 '21 at 15:11
  • 1
    @i486 see my answer. A part in question is a display-name, which is a phrase according to 3.4; phrase is defined in 3.2.5 as a word as either atom or a quoted-string. I.e. it is possible for it to not to be a quoted-string. Feb 15 '21 at 19:21

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.