Skip to main content

Crate email_validator_rfc5322

Crate email_validator_rfc5322 

Source
Expand description

RFC 5322 compliant email address validator

This crate provides email validation according to RFC 5322 Section 3.4.1 with support for:

  • Standard email addresses (user@example.com)
  • Quoted local parts ("john doe"@example.com)
  • IP literal domains (user@[192.168.1.1], user@[IPv6:2001:db8::1])
  • All RFC 5322 special characters in local parts

§Examples

use email_validator_rfc5322::{validate_email, is_valid_email};

// Simple validation
assert!(is_valid_email("user@example.com"));
assert!(!is_valid_email("invalid"));

// With error details
match validate_email("user@example.com") {
    Ok(()) => println!("Valid email"),
    Err(e) => println!("Invalid: {:?}", e),
}

§RFC Compliance

This implementation follows:

  • RFC 5322: Internet Message Format (email syntax)
  • RFC 5321: SMTP (length limits: 64 local, 255 domain, 254 total)
  • RFC 1035: DNS (label length limit: 63)

Enums§

EmailValidationError
Validation error with detailed information about what failed

Functions§

is_valid_email
Returns true if the email address is valid according to RFC 5322
validate_email
Validates an email address according to RFC 5322

Type Aliases§

ValidationResult
Result type for email validation