Parsing of mail addresses
Addresses indicate the senders and recipients of messages and correspond to either an individual mailbox or a group of mailboxes.
Usually the user name
The domain of the mailbox
local_part * domain option
local_part@domain as O'Caml type. The domain may be
mailbox has a name, optionally a route (not used nowadays), and
a formal address specification.
group has a name, and consists of a number of mailboxes.
The union of
exception Parse_error of
int * string
A parsing error. The
int is the position in the parsed string
val parse :
string -> t list
Parse a list of addresses in string representation, and return them as list of mailboxes or groups.
parse "email@example.com"returns a single
mailboxwithout name and route, and the given spec
parse "Gerd Stolpmann <firstname.lastname@example.org>"returns a single
mailboxwith name and spec, but without route
parse "email@example.com, ghi"returns two
mailboxes without name and route, and the two specs. The second address only has a local part, but no domain.
parse "g:firstname.lastname@example.org, Me <email@example.com>;, firstname.lastname@example.org"returns one group
email@example.com, and another
Old-style naming of mailboxes is not supported (e.g. "firstname.lastname@example.org (Gerd Stolpmann)" - the part in parentheses is simply ignored.