Crate email_address_parser[][src]

Expand description

An RFC 5322 compliant email address parser.


You can parse string for email address like this.

use email_address_parser::EmailAddress;

let email = EmailAddress::parse("", None).unwrap();
assert_eq!(email.get_local_part(), "foo");
assert_eq!(email.get_domain(), "");

For an input string that is an invalid email address, it returns None.

use email_address_parser::EmailAddress;

assert!(EmailAddress::parse("", None).is_none());

To parse an email address with obsolete parts (as per RFC 5322) in it, pass None as the second argument to have non-strict parsing.

use email_address_parser::*;

let email = EmailAddress::parse("\u{0d}\u{0a} \u{0d}\u{0a}", Some(ParsingOptions::new(true)));

Unicode support

In compliance to RFC 6532, it supports parsing, validating, and instantiating email addresses with Unicode characters.

use email_address_parser::*;

assert!(format!("{}", EmailAddress::new("foö", "bü", None).unwrap()) == "foö@bü");
assert!(format!("{}", EmailAddress::parse("foö@bü", None).unwrap()) == "foö@bü");
assert!(EmailAddress::is_valid("foö@bü", None));


Email address struct.

Options for parsing.