Mrmime.MailboxSourceType of mailbox. Normally, a mailbox is composed of two parts:
"<" and ">").There is an alternate simple form of a mailbox where the addr-spec address appears alone, without the recipient's name or the angle brackets.
escape_string x returns a safe string where control characters are escaped (\x00, \x5c, \a, \b, \t, \n, \v, \f, \r and \x22 - double quote).
A phrase in the context of the mailbox is a display-name that indicates the name of the recipient. We provide an easily way to make it and keep conformances according standards.
A domain can be constructed in several ways. The most common way is:
Local part of a mailbox is a non-empty list of word elements. You can construct local-part like this:
val make :
?name:Emile.phrase ->
Emile.local ->
?domains:Emile.domain list ->
Emile.domain ->
tmake ?name local ?domains domain returns a mailbox with local-part local, first domain domain, others domains domains (default is an empty list) and an optional name.
let me =
make Local.(v [ w "romain"; w "calascibetta" ])
~domains:[ Domain.(v domain [ a "gmail"; a "com" ]) ]
Domain.(v domain [ a "x25519"; a "net" ]) ;;
val me : t = ....
to_string me ;;
- : string = "<@gmail.com:romain.calascibetta@x25519.net>"@ operator constructs an usual e-mail address:
let me = Local.[ w "romain"; w "calascibetta" ] @ Domain.(domain, [ a "x25519"; a "net" ]) ;;
val me : t = { name= None
; local= [ `Atom "romain"; `Atom "calascibetta" ]
; domain= (`Domain ["x25519"; "net"], []) }
to_string me ;;
- : string = "romain.calascibetta@x25519.net"With only one domain and without a display-name. If you want to put multiple domains, you should use make instead. If you want to put a phrase, you can use with_phrase.
@ operator can raise Invalid_argument where local-part or domain fail to normalize inputs according standards (see Local.make and Domain.make).
with_name phrase t put or replace display name of mailbox t.
let dbuenzli = with_name Phrase.(v [ w "Daniel"; e ~encoding:q "Bünzli" ]) dbuenzli
val dbuenzli : t = ...
(* Stringify dbuenzli! *)
to_string dbuenzli ;;
- : string = "Daniel =?UTF-8?Q?B=C3=BCnzli?= <daniel.buenzli@erratique.ch>"to_string x returns a string which represents x as is it in a e-mails.
of_string x returns a t from a well-formed string x according RFC 5322. A mailbox can have several forms and can include FWS tokens. Some examples of what is allowed:
thomas@gazagnaire.orgHannesm <hannes@menhert.org><anil@recoil.org>Romain Calascibetta <@gmail.com:romain.calascibetta@x25519.net>Daniel =?UTF-8?Q?B=C3=BCnzli?= <daniel.buenzli@erratique.ch>Any encoded-word are normalized to a valid UTF-8 string (even if charset is something else than "UTF-8").