Jump to content

Email address: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Hustvedt (talk | contribs)
→‎RFC specification: Use a RFC 1918 IP for the example
Without this, it doesn't make sense, leave the link until you/we/i find a better example.
Line 100: Line 100:
An e-mail address is generally recognised as being two parts separated by the [[at-sign]], this in itself is a basic form of validation. However, the technical specification detailed in RFC 822, and subsequent RFCs goes far beyond this, offering very complex and strict restrictions. <ref>[http://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx I Knew How To Validate An Email Address Until I Read The RFC<!-- Bot generated title -->]</ref>
An e-mail address is generally recognised as being two parts separated by the [[at-sign]], this in itself is a basic form of validation. However, the technical specification detailed in RFC 822, and subsequent RFCs goes far beyond this, offering very complex and strict restrictions. <ref>[http://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx I Knew How To Validate An Email Address Until I Read The RFC<!-- Bot generated title -->]</ref>


Trying to match these restrictions is an extremely difficult and complex task, often resulting in long [[regular expression]]s that is too hard to actually be practical.<ref>[http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html Mail::RFC822::Address<!-- Bot generated title -->]</ref> RFC 2822 introduced the notion of ''obsolete syntax'' (reinforced by the subsequent RFC 5322) in an attempt to explicitly define the gap between the more liberal syntax that a server is willing to accept and interpret and the more conservative one that it is committed to generate. An application of [[Postel's Law]].
Trying to match these restrictions is an extremely difficult and complex task<ref>[http://www.hm2k.com/posts/what-is-a-valid-email-address HM2K.com » What is a valid email address?]</ref>, often resulting in long [[regular expression]]s that is too hard to actually be practical.<ref>[http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html Mail::RFC822::Address<!-- Bot generated title -->]</ref> RFC 2822 introduced the notion of ''obsolete syntax'' (reinforced by the subsequent RFC 5322) in an attempt to explicitly define the gap between the more liberal syntax that a server is willing to accept and interpret and the more conservative one that it is committed to generate. An application of [[Postel's Law]].


Practicality plays a major role once you discover that many mail servers have very relaxed validation, that allow and handle e-mail addresses that are disallowed according to the RFC. Because of this, we are forced to take a different approach, adopting relaxed validation and instead verifying the e-mail address and its various parts against the relevant systems (such as [[Domain Name System|DNS]] for the domain part).
Practicality plays a major role once you discover that many mail servers have very relaxed validation, that allow and handle e-mail addresses that are disallowed according to the RFC. Because of this, we are forced to take a different approach, adopting relaxed validation and instead verifying the e-mail address and its various parts against the relevant systems (such as [[Domain Name System|DNS]] for the domain part).

Revision as of 09:21, 17 October 2008

An e-mail address identifies a location to which e-mail messages can be delivered. An e-mail address on the modern Internet looks like, for example, jsmith@example.com and is usually read as "jsmith at example dot com". Many earlier e-mail systems had different formats for e-mail addresses and because modern e-mail systems are partially based on, and compatible with these older systems, the exact format of an e-mail address is complicated and frequently misunderstood.

Overview

Most e-mail on the internet uses the Simple Mail Transfer Protocol (SMTP), which is defined in the internet standards RFC 5321 and RFC 5322.

E-mail addresses, such as jsmith@example.com, have two parts. The part before the @ sign is the local-part of the address, often the username of the recipient, and the part after the @ sign is the domain which is a hostname where the e-mail will be sent. Roughly speaking, the hostname is looked up in the Domain Name System to find the mail transfer agent or Mail eXchangers (MXs) accepting e-mail for that address.

The domain may have semantic meaning for any mail-system handling the address; the meaning is well-defined and changes to meaning involve changing every mail-server in existence. The local-part, by contrast, is supposed to be opaque to every mail-system except the system which is authoritative for the domain. This is what makes e-mail a federated system.

When a host receives an e-mail, it will be delivered to an e-mail mailbox. Some hosts allow more than one e-mail address to be sent to the same mailbox via an e-mail alias or even allow a catch-all address where the local-part can be undefined and e-mail would be delivered to a configured and existing e-mail address.

Often, the domain of an e-mail address is that of an e-mail service, such as Google's Gmail, Microsoft's Hotmail, etc. The domain can also be the domain name of the organization that the recipient represents, or of the recipient's personal site.

Addresses found in the header fields of e-mail should not be considered authoritative, because SMTP has no generally-required mechanisms for authentication. Forged e-mail addresses are often seen in spam, phishing, and many other internet-based scams; this has led to several initiatives which aim to make such forgeries easier to spot.

To indicate who the message is intended for, a user can use the "display name" of the recipient followed by the address specification surrounded by angled brackets, for example: John Smith <john.smith@example.com>.

Earlier forms of e-mail addresses included the somewhat verbose notation required by X.400, and the UUCP "bang path" notation, in which the address was given in the form of a sequence of computers through which the message should be relayed. This was widely used for several years, but was superseded by the generally more convenient SMTP form.

RFC specification

E-mail addresses are formally defined in RFC 5322 (mostly section 3.4.1) and to a lesser degree RFC 5321. An e-mail address is a string of a subset of ASCII characters separated into 2 parts by an "@" (at sign), a "local-part" and a domain, that is, local-part@domain.

The "local-part" of an e-mail address can be up to 64 characters and the domain name a maximum of 255 characters. Clients may attempt to use larger objects, but they must be prepared for the server to reject them if they cannot be handled by it.[1]

The local-part of the e-mail address may use any of these ASCII characters:

  • Uppercase and lowercase English letters (a-z, A-Z)
  • Digits 0 through 9
  • Characters ! # $ % & ' * + - / = ? ^ _ ` { | } ~
  • Character . provided that it is not the first nor last character, nor may it appear two or more times consecutively.

Additionally, quoted-strings (ie: "John Doe"@example.com) are permitted, thus allowing characters that would otherwise be prohibited, however they do not appear in common practice. RFC 5321 also warns that "a host that expects to receive mail SHOULD avoid defining mailboxes where the Local-part requires (or uses) the Quoted-string form".

The local-part is case sensitive, so "jsmith@example.com" and "JSmith@example.com" may be delivered to different people. This practice is, however, discouraged by RFC 5321. However, only the authoritative mail-servers for a domain may make that decision.

Notwithstanding the addresses permitted by these standards, some systems impose more restrictions on e-mail addresses, both in e-mail addresses created on the system and in e-mail addresses to which messages can be sent. Hotmail, for example, only allows creation of e-mail addresses using alphanumerics, dot (.), underscore (_) and hyphen (-), and will not allow sending mail to any e-mail address containing ! # $ % * / ? | ^ { } ` ~[2]. The domain name is much more restricted, as they must match the requirements for a hostname, consisting of letters, digits, hyphens and dots. In addition, the domain may be an IP address literal, surrounded by square braces, such as jsmith@[192.168.2.1] (this is rarely seen, except in spam).

The informational RFC 3696 written by the author of RFC 5321 explains the details in a readable way, with a few minor errors noted in the 3696 errata.

Email Address Internationalization

Email Address Internationalization is an IETF working group devoted to internationalization issues in email addresses[3]. The only published RFC to date is RFC 4952, envisioning changes to the mail header environment to permit the full range of Unicode characters and an SMTP Extension to permit UTF-8 mail addressing, among other things. The list of valid examples below is thus expected to undergo significant additions.

RFC examples

RFC Valid e-mail addresses

  • abc@example.com
  • Abc@example.com
  • aBC@example.com
  • abc.123@example.com
  • 1234567890@example.com
  • _______@example.com
  • abc+mailbox/department=shipping@example.com
  • !#$%&'*+-/=?^_`.{|}~@example.com (all of these characters are allowed)
  • "abc@def"@example.com (anything goes inside quotation marks)
  • "Fred \"quota\" Bloggs"@example.com (however, quotes need escaping)

RFC invalid e-mail addresses

  • Abc.example.com (character @ is missing)
  • Abc.@example.com (character dot(.) is last in local part)
  • Abc..123@example.com (character dot(.) is double)
  • A@b@c@example.com (only one @ is allowed outside quotations marks)
  • ()[]\;:,<>@example.com (none of the characters before the @ is allowed outside quotation marks)

Common local-part semantics

According to RFC 5321 2.3.11 Mailbox and Address, "...the local-part MUST be interpreted and assigned semantics only by the host specified in the domain part of the address.".

This means that no assumptions can be made about the meaning of the local-part of another mail server. It is entirely up to the configuration of the mail server.

Local-part normalization

A mail server is able to give meaning to the local-part it handles. For example, case-insensitivity, where it is assumed that regardless of whether the local-part is in lowercase or uppercase the email is intended for the same account, although this is extremely common, it is not always true, and depends on the mail server configuration.

Another example, provided by Google Mail, is where the system ignores all dots in the local-part for the purposes of determining account identity.[4]

This means that if a user creates an account called your.username then nobody else can create accounts that are confusingly similar, such as your.user.name or yourusername, as they will all belong to an existing account.

Sub-addressing

Some mail services allow a user to append a +tag qualifier to their e-mail address (e.g., joeuser+tag@example.com). The text of tag can be used to apply filtering.

However, some mail servers violate RFC 5322, and the recommendations in RFC 3696, by refusing to send mail addressed to a user on another system merely because the local-part of the address contains the plus sign (+). Users of these systems cannot use plus addressing.

On the other hand, most qmail and courier installations support the use of a dash '-' as a separator within the local-part, such as joeuser-tag@example.com or joeuser-tag-sub-anything-else@example.com. This allows qmail through .qmail-default or .qmail-tag-sub-anything-else files to sort, filter, forward, or run application based on the tagging system established.

Disposable e-mail addresses of this form, using various separators between the base name and tag are supported by several e-mail services, including Runbox (plus and minus), Google Mail (plus), Yahoo! Mail Plus (minus)[5], and FastMail (plus)[6].

The name sub-addressing is the generic term (used for plus-addressing and minus-addressing) found in some IETF standards-track documents, such as RFC 5233.

Validation

It's easy to forget that e-mail addresses aren't only used on a mail client or mail server, often e-mail addresses are seen to be used outside of this system. Thus, when using an e-mail address in another system (such as a website), the user data (entered via an online form) must be validated.

An e-mail address is generally recognised as being two parts separated by the at-sign, this in itself is a basic form of validation. However, the technical specification detailed in RFC 822, and subsequent RFCs goes far beyond this, offering very complex and strict restrictions. [7]

Trying to match these restrictions is an extremely difficult and complex task[8], often resulting in long regular expressions that is too hard to actually be practical.[9] RFC 2822 introduced the notion of obsolete syntax (reinforced by the subsequent RFC 5322) in an attempt to explicitly define the gap between the more liberal syntax that a server is willing to accept and interpret and the more conservative one that it is committed to generate. An application of Postel's Law.

Practicality plays a major role once you discover that many mail servers have very relaxed validation, that allow and handle e-mail addresses that are disallowed according to the RFC. Because of this, we are forced to take a different approach, adopting relaxed validation and instead verifying the e-mail address and its various parts against the relevant systems (such as DNS for the domain part).

References

  • RFC 5321: Simple Mail Transfer Protocol
  • RFC 5322: Internet Message Format
  • RFC 3696: Application Techniques for Checking and Transformation of Names
  • RFC 2142: Mailbox names for common services, roles and functions

Footnotes

  1. ^ RFC 5321, section 4.5.3.1. Size Limits and Minimums explicitly details protocol limits.
  2. ^ The character limitation is written in plain English in the subscription page "Sign up for Windows Live". Retrieved 2008-07-26.. However, the phrase is hidden, thus one has to either check the availability of an invalid ID, e.g. me#1, or resort to alternative displaying, e.g. no-style or source view, in order to read it.
  3. ^ "Eai Status Pages". Email Address Internationalization (Active WG). IETF. Retrieved 2008-07-26.
  4. ^ Google Mail - help center article
  5. ^ help.yahoo.com
  6. ^ FastMail FAQ
  7. ^ I Knew How To Validate An Email Address Until I Read The RFC
  8. ^ HM2K.com » What is a valid email address?
  9. ^ Mail::RFC822::Address

See also