Crates.io | email-address-parser |
lib.rs | email-address-parser |
version | 2.0.0 |
source | src |
created_at | 2020-08-30 17:36:15.793382 |
updated_at | 2023-05-31 18:06:08.369826 |
description | An RFC 5322, and RFC 6532 compliant email address parser. |
homepage | https://github.com/Sayan751/email-address-parser |
repository | https://github.com/Sayan751/email-address-parser |
max_upload_size | |
id | 282771 |
size | 27,085 |
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());
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"));