|
The code makes extensive use of regular expressions to check email address
components for RFC compliance:
- Local Part (preceding the last '@' symbol; ASCII hex value 40)
- Domain Part (following the last '@' symbol; ASCII hex value 40)
- IP Address Literal (if used instead of a domain name)
- IP v4 Address Literal
- IP v6 Address Literal (full & compressed)
- IP v6 v4 Address Literal (full & compressed)
RFC Requirements
An email address must consist of a local part and a domain part separated by an @ symbol (x40) with a combined length of no more than 256 characters. -
RFC 3696 - 3 & errata,
RFC 2822 - 3.4.1
Local Part:
- A non-quoted local part may consist of alpha (a-z) (x61-x7A) (A-Z) (x41-x5A), numeric (0-9) (x30-x39) and the following characters: !#$%&'*+-/=?^_`{|}~ (x21, x23, x24, x25, x26, x27, x2A, x2B, x2D, x2F, x3D, x3F, x5E, x5F, x60, x7B, x7C, x7D, x7E) respectively. -
RFC 3696 - 3 & errata,
RFC 2822 - 3.2.4
- Dots may also be present in the local part, but can not be the first nor last character, nor adjacent to another dot (.) (x2E). -
RFC 3696 - 3,
RFC 2822 - 3.2.4
- The local part may be a double quoted (") (x22) string consisting of any ASCII characters except the following: NULL (x00), TAB (x09), LF (x0A), CR (x0D), " (x22), \ (x5C). However the following are permitted in a local part double quoted string if escaped (preceded by a backslash, (\), (x5C)): x01 thru x09, x0B, x0C, x0E thru x7F. -
RFC 3696 - 3 & errata,
RFC 2822 - 3.2.1 - 3.2.5
- Maximum length of the local part is 64 characters. -
RFC 3696 - 3 & errata,
RFC 2821 - 4.5.3.1
Domain Part:
- Domain part consists of dot separated labels of 1 to 63 characters each, up to a maximum total length of 255 characters (including dot delimiters). -
RFC 3696 - 2,
RFC 1035 2.3.1,
RFC 2821 - 4.5.3.1,
RFC 2181 - 11
- Domain labels must begin and end with an alpha (a-z) (x61-x7A) (A-Z) (x41-x5A) or numeric (0-9) (x30-x39) character and may include hyphens (-) (x2D).
In addition, the TLD (last label) must contain at least one alpha character or hyphen (not all numeric), and be at least two characters. -
RFC 3696 - 2,
RFC 1035 2.3.1,
RFC 1123 - 2.1
- Domain must be fully qualified (FQDN) and resolvable to an A or MX domain name system record. - RFC 2821 - 3.6
- Domain may be an IP v4, IP v6 or IP v6/v4 address literal. -
RFC 3696 - 3,
RFC 2821 - 4.1.3,
RFC 2373 - 2.2
Please note:
As of RFC's 2822 in 2001 & RFC 3696 (and errata) in 2004, backslash (x5C), is not an RFC compliant component of a non-quoted email address local-part. "Stated differently, any ASCII graphic (printing) character other than the at-sign ("@"), backslash, double quote, comma, or square brackets may appear without quoting. If any of that list of excluded characters are to appear, they must be quoted.
- RFC 3696 section 3. Restrictions on email addresses"
Also, "the upper limit on address lengths (local-part@domain-part) should normally be considered to be 256.
- RFC 3696 - errata"
And also, contrary to some, domain names beginning with a digit are permitted.
- RFC 1123 - 2.1
Copyright © 2007, 2008, Simon Slick. All Rights Reserved.
|