Legend:
Library
Module
Module type
Parameter
Class
Class type
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.
let name = Phrase.(v [ w "Daniel"; w "B" ]) ;;
val name : phrase
Phrase.to_string name ;;
- : string = "Daniel B"
About special encoding/charset, a `Word can store a valid UTF-8 string. Otherwise, you can use an Encoded_word.t to keep special characters:
let name = Phrase.(v [ w "Daniel"; e ~encoding:q "Bünzli" ]) ;;
- name : phrase
Phrase.to_string name ;;
- "Daniel =?UTF-8?Q?B=C3=BCnzli?=" : string
NOTE: we accept only valid UTF-8 contents. Other charset (like latin1) are NOT allowed - we can compute them but we choose to never produce them.
w produces a safe word. w will try to escape control characters and verify if contents respects standards. Otherwise, w raises an Invalid_argument. `Word produced by w can be surrounded by double-quote.
e is an alias of Encoded_word.make_exn. About `Encoded word, user can choose the way to encode the word. b for a Base64 encoding or q for a Quoted-Printable encoding. Both accept only UTF-8 contents - we don't accept any other charset.
word x tries to normalize x as a `Word according RFC 5322. It returns Error if x does not respect standards. If contents is an UTF-8 contents, word will surround x with double-quote and will escape control characters (see escape_string).
NOTE: UTF-8 is allowed in e-mails according RFC 6532.