Function mailparse::addrparse[][src]

pub fn addrparse(addrs: &str) -> Result<MailAddrList, MailParseError>
Expand description

Convert an address field from an email header into a structured type. This function handles the most common formatting of to/from/cc/bcc fields found in email headers. Note that if you are attempting to parse the value of a MailHeader, it is better (both for correctness and performance to use the addrparse_header function instead of this one. Correctness is impacted because of the way encoded words within the header are processed; using MailHeader::get_value() will decode encoded words, which may then contain characters like commas that affect how addrparse parses the value. This can produce incorrect results in some cases; using addrparse_header will avoid this problem.

Examples

    use mailparse::{addrparse, MailAddr, SingleInfo};
    match &addrparse("John Doe <john@doe.com>").unwrap()[0] {
        MailAddr::Single(info) => {
            assert_eq!(info.display_name, Some("John Doe".to_string()));
            assert_eq!(info.addr, "john@doe.com".to_string());
        }
        _ => panic!()
    };