#rfc-5322 #parser #rfc-6532

email-address-parser

An RFC 5322, and RFC 6532 compliant email address parser

17 releases (5 stable)

2.0.0 May 31, 2023
2.0.0-rc3 Dec 26, 2022
2.0.0-rc2 Aug 27, 2022
2.0.0-rc1 Oct 11, 2021
0.3.0-rc2 Aug 30, 2020

#54 in Email

Download history 1991/week @ 2024-03-14 1681/week @ 2024-03-21 1376/week @ 2024-03-28 1202/week @ 2024-04-04 1788/week @ 2024-04-11 1425/week @ 2024-04-18 1021/week @ 2024-04-25 1789/week @ 2024-05-02 2078/week @ 2024-05-09 1094/week @ 2024-05-16 1570/week @ 2024-05-23 1169/week @ 2024-05-30 2052/week @ 2024-06-06 2039/week @ 2024-06-13 2419/week @ 2024-06-20 1635/week @ 2024-06-27

8,424 downloads per month
Used in 24 crates (11 directly)

MIT license

27KB
353 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

~2.2–3MB
~62K SLoC