package mrmime

  1. Overview
  2. Docs

A domain can be constructed in several ways. The most common way is:

let isomorphism = Domain.(v domain [ a "isomorphis"; a "me" ]) ;;
val isomorphism : domain = `Domain ["isomorphis"; "me"]
Domain.to_string isomorphism ;;
- : string = "isomorphis.me"

You can specify an IP (v4 or v6) address like:

let localhost = Domain.(v ipv4 Ipaddr.V4.localhost) ;;
val localhost : domain = `Addr (IPv4 127.0.0.1)
Domain.to_string localhost ;;
- : string = "[127.0.0.1]"

At the end, and according RFC 5322, it's possible to specify a `Literal domain like this:

let x25519 = Domain.(v literal "x25519") ;;
val x25519 : domain = `Literal "x25519"
Domain.to_string x25519 ;;
- : string = "[x25519]"

However, this last kind conforms only RFC 5322 - RFC 5321 (SMTP protocol) does not recognize this kind of domain.

type atom = [
  1. | `Atom of string
]
type literal = [
  1. | `Literal of string
]
type 'a domain =
  1. | :: : atom * 'a domain -> 'a Mrmime__.Peano.s domain
  2. | [] : Mrmime__.Peano.z domain
type 'a t

Kind of domain. RFC 5322 and RFC 5321 allows several kinds of domain:

  • An usual domain which is a non-empty list of atom elements
  • A Literal_domain.t
  • A `Literal domain which is a string surrounded by brackets.
val atom : string -> (atom, [> `Msg of string ]) Stdlib.result

atom x returns a safe atom element. If x does not respect RFC 5322, it returns Error. It accepts any characters excepts controls, space and specials characters - for instance, brackets are not allowed.

val atom_exn : string -> atom

Same as atom but raises an Invalid_argument instead Error.

val a : string -> atom

Alias of atom_exn.

val literal : string -> (literal, [> `Msg of string ]) Stdlib.result

literal x returns a literal domain. If x does not respect RFC 5321, it returns Error. It will try to escape control characters (with escape_string).

val literal_exn : string -> literal

Same as literal but raises an Invalid_argument instead to return Error.

val domain : 'a domain t

Kind of domain.

val ipv4 : Ipaddr.V4.t t
val ipv6 : Ipaddr.V6.t t
val extension : (string * string) t
val default : string t

Kind of literal.

val make : 'a t -> 'a -> (Emile.domain, [> `Msg of string ]) Stdlib.result

make kind v returns a safe domain. It can fail if an user-defined literal-domain (Literal_domain.extension), a literal domain or a domain don't follow standards:

val of_list : string list -> (Emile.domain, [> `Msg of string ]) Stdlib.result

of_list l returns a domain from a non-empty list of well-formed atom elements. Otherwise, it returns an error.

val v : 'a t -> 'a -> Emile.domain

Same as make but raises an Invalid_argument instead Error.

val to_string : Emile.domain -> string

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

OCaml

Innovation. Community. Security.