package mrmime

  1. Overview
  2. Docs

Local part of a mailbox is a non-empty list of word elements. You can construct local-part like this:

let local = Local.(v [ w "romain"; w "calascibetta" ]) ;;
val local : local = [ `Atom "romain"; `Atom "calascibetta" ]

Spaces and control characters are allowed in the local-part:

let local = Local.(v [ w "Romain Calascibetta"; w "to+mrmime" ]) ;;
val local : local = [ `String "Romain Calascibetta"; `Atom "to+mrmime" ]
Local.to_string local ;;
- : string = "\"Romain Calascibetta\".to+mrmime"

NOTE: + permits your MUA to tag e-mails received with this local-part.

Valid UTF-8 string is allowed according RFC 6532 - and will be surrounded by double-quote.

type 'a local =
  1. | [] : Mrmime__.Peano.z local
  2. | :: : Emile.word * 'a local -> 'a Mrmime__.Peano.s local
val w : string -> Emile.word

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.

val word : string -> (Emile.word, [> Rresult.R.msg ]) result

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.

val word_exn : string -> Emile.word

Same as word but raises an exception instead to return Error.

val coerce : 'a Mrmime__.Peano.s local -> Emile.local

coerce l returns a valid and safe local.

val make : 'a local -> (Emile.local, [> Rresult.R.msg ]) result

make l returns a local only if l is a non-empty list.

val of_list : string list -> (Emile.local, [> Rresult.R.msg ]) result

of_list l returns a local-part from a non-empty list of well-formed words. Otherwise, it returns an error.

val v : 'a local -> Emile.local

Same as make but raises an exception instead to return Error.

val to_string : Emile.local -> string

to_string x returns a string which represents x as it is in an e-mail.

OCaml

Innovation. Community. Security.