Function mailparse::addrparse_header[][src]

pub fn addrparse_header(
    header: &MailHeader<'_>
) -> Result<MailAddrList, MailParseError>
Expand description

Take a MailHeader that contains addresses in the value (e.g. from/to/cc/bcc) and produce a structured type representing those addresses.

Examples

    use mailparse::{addrparse_header, parse_mail, MailAddr, MailHeaderMap, SingleInfo};
    let mail = parse_mail(b"From: John Doe <john@doe.com>\n\nBlah Blah").unwrap();
    match &addrparse_header(mail.headers.get_first_header("From").unwrap()).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!()
    };