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

email-address-parser

An RFC 5322, and RFC 6532 compliant email address parser

13 releases (4 stable)

new 1.0.3 Sep 15, 2021
1.0.1 Apr 24, 2021
1.0.0 Sep 6, 2020
0.3.0-rc2 Aug 30, 2020
0.2.0-rc9 Aug 30, 2020

#30 in Email

Download history 11/week @ 2021-05-27 15/week @ 2021-06-03 46/week @ 2021-06-10 59/week @ 2021-06-17 19/week @ 2021-06-24 21/week @ 2021-07-01 30/week @ 2021-07-08 62/week @ 2021-07-15 38/week @ 2021-07-22 147/week @ 2021-07-29 56/week @ 2021-08-05 39/week @ 2021-08-12 57/week @ 2021-08-19 111/week @ 2021-08-26 116/week @ 2021-09-02 73/week @ 2021-09-09

265 downloads per month

MIT license

23KB
345 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

~3MB
~52K SLoC