Email Address Format (RFC 5322)
An email address has two parts separated by @: the local part (mailbox identifier) and the domain (mail server). While most addresses look simple, the RFC 5322 specification permits surprisingly complex syntax.
The local part allows letters, digits, and certain special characters (. ! # $ % & ' * + - / = ? ^ _ ` { | } ~). Dots are permitted but cannot be consecutive or appear at the start or end. Quoted strings ("john..doe"@example.com) allow almost any character, including spaces and at-signs, though very few mail servers support this in practice. Plus addressing (user+tag@domain.com) is widely used for filtering. Gmail, Outlook, and Fastmail all route user+anything to the user mailbox.
The domain part must be a valid hostname: labels separated by dots, each 1-63 characters, using letters, digits, and hyphens (no leading or trailing hyphens). Internationalized Domain Names (IDN) allow non-ASCII characters via Punycode encoding. For example, user@xn--nxasmq6b.com represents a Greek domain. The total address length is capped at 254 characters (RFC 5321). Test edge cases to see which patterns your validation catches.