#email-address #parser #rfc-5322 #rfc-6532

email-address-parser

An RFC 5322, and RFC 6532 compliant email address parser

16 releases (4 stable)

2.0.0-rc3 Dec 26, 2022
2.0.0-rc2 Aug 27, 2022
2.0.0-rc1 Oct 11, 2021
1.0.3 Sep 15, 2021
0.2.0-rc9 Aug 30, 2020

#28 in Email

Download history 1830/week @ 2022-11-29 1684/week @ 2022-12-06 1093/week @ 2022-12-13 309/week @ 2022-12-20 417/week @ 2022-12-27 657/week @ 2023-01-03 1002/week @ 2023-01-10 1862/week @ 2023-01-17 1423/week @ 2023-01-24 1911/week @ 2023-01-31 1434/week @ 2023-02-07 1756/week @ 2023-02-14 1602/week @ 2023-02-21 4255/week @ 2023-02-28 1972/week @ 2023-03-07 2283/week @ 2023-03-14

10,456 downloads per month
Used in 9 crates (3 directly)

MIT license

24KB
356 lines

email-address-parser

An RFC 5322, and RFC 6532 compliant email address parser.

You can parse string for email address like this.

use email_address_parser::EmailAddress;

let email = EmailAddress::parse("foo@bar.com", Some(true)).unwrap();
assert_eq!(email.get_local_part(), "foo");
assert_eq!(email.get_domain(), "bar.com");

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

use email_address_parser::EmailAddress;

assert!(EmailAddress::parse("test@-iana.org", Some(true)).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.

let email = EmailAddress::parse("\u{0d}\u{0a} \u{0d}\u{0a} test@iana.org", None);
assert!(email.is_some());

Unicode support

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

assert!(format!("{}", EmailAddress.new("foö", "bücher.de")) == "foö@bücher.de");
assert!(format!("{}", EmailAddress.parse("foö@bücher.de")) == "foö@bücher.de");
assert!(EmailAddress.isValid("foö@bücher.de"));

Dependencies

~4MB
~69K SLoC