pub fn parse_mailbox<'a>(
value: &'a [u8],
limits: &Limits,
) -> Result<Mailbox<'a>, ParseError>Expand description
Parses a mailbox (RFC 5322 section 3.4): [display-name] "<" addr-spec ">" or a bare addr-spec. The display name is checked as a phrase
(atoms, dots, quoted strings, comments, UTF-8) and returned raw.
§Errors
As parse_addr_spec; ErrorKind::UnbalancedComment,
ErrorKind::CommentTooDeep.
§Examples
use parse_net::{mail, Limits};
let m = mail::parse_mailbox(b"\"Doe, John\" <john@example.com>", &Limits::DEFAULT)?;
assert_eq!(m.display_name, Some(&b"\"Doe, John\""[..]));
assert!(mail::parse_mailbox(b"john@example.com", &Limits::DEFAULT)?.display_name.is_none());