package emile

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module EmileSource

Emile module, parser of e-mail address.

Sourcetype raw =
  1. | Quoted_printable of string
  2. | Base64 of [ `Dirty of string | `Clean of string | `Wrong_padding ]

An e-mail address can contain as a phrase an encoded string. Standards describe 2 kinds of encoding:

  • Quoted Printable: used to insert hexadecimal value with the = operator.
  • Base 64: string encoded in MIME's Base64

Parser already decodes encoded

raw

, the client can use it as is.

Sourcetype word = [
  1. | `Atom of string
  2. | `String of string
]

The local part of an e-mail address is composer by two kinds of word:

  • `Atom is string as is.
  • `String is a string surrounded by double-quote to allow white-space.
Sourcetype local = word list

Local part of e-mail address.

Sourcetype addr =
  1. | IPv4 of Ipaddr.V4.t
  2. | IPv6 of Ipaddr.V6.t
  3. | Ext of string * string

Subset of domain described by RFC5321 which contains 3 kinds of address:

  • IPv4: a valid IPv4 address
  • IPv6: a valid IPv6 address
  • Ext (ldh, value): an extended kind of domain recognized by ldh which valus is value

Parser of IPv4 and IPv6 was done by Ipaddr. An extended kind need to be resolved by the client.

Sourcetype domain = [
  1. | `Domain of string list
  2. | `Addr of addr
  3. | `Literal of string
]

Domain part of e-mail address. A domain integrate kinds from RFC5321 (see addr), a domain described by RFC5322 and a `Literal which is the last best-effort value possible as a domain.

Emile does not resolve domain.

Sourcetype phrase = [ `Dot | `Word of word | `Encoded of string * raw ] list

A phrase is a sentence to associate a name with an e-mail address or a group. `Encoded value is not normalized on the charset specifed. The encoded's string is decoded as is only.

Sourcetype mailbox = {
  1. name : phrase option;
  2. local : local;
  3. domain : domain * domain list;
}

A mailbox is an e-mail address. It contains an optionnal name (see phrase), a local-part see {!local

}

and one or more domain(s).

Sourcetype group = {
  1. group : phrase;
  2. mailboxes : mailbox list;
}

A groyp is a named set of mailbox.

Sourcetype t = [
  1. | `Mailbox of mailbox
  2. | `Group of group
]

The Emile's type.

Pretty-printer

Sourceval pp_addr : addr Fmt.t
Sourceval pp_domain : domain Fmt.t
Sourceval pp_word : word Fmt.t
Sourceval pp_local : local Fmt.t
Sourceval pp_raw : raw Fmt.t
Sourceval pp_phrase : phrase Fmt.t
Sourceval pp_mailbox : mailbox Fmt.t
Sourceval pp_group : group Fmt.t
Sourceval pp : t Fmt.t

Equal & Compare

Sourcetype 'a equal = 'a -> 'a -> bool
Sourcetype 'a compare = 'a -> 'a -> int
Sourceval case_sensitive : string -> string -> int

Alias of String.compare.

Sourceval case_insensitive : string -> string -> int

case_insensitive a b maps lowercase_ascii and compare them with String.compare. We do not map UTF8 value.

Sourceval equal_word : compare:(string -> string -> int) -> word equal

equal ~compare a b tests if word a and word b are semantically equal. compare specify implementation to compare two string (ie. to be case-sensitive or not).

Sourceval compare_word : ?case_sensitive:bool -> word compare

compare_word ?case_sensitive a b compares word a and word b semantically. From standards, word SHOULD be case-sensitive, the client can notice the behaviour by ?case_sensitive (default is true).

Sourceval equal_raw : compare:string compare -> raw equal

equal_raw a b tests if raw a and raw b are semantically equal. Semantically equal means we compare raw's content, by this way, a Base64 raw could be equal to a Quoted_printable raw if and only if string are equal.

Sourceval compare_raw : compare:string compare -> raw compare

compare_raw a b compares raw a and raw b semantically.

Sourceval equal_phrase : phrase equal

equal_phrase a b tests if phrase a and phrase b are semantically equal. In this case, the comparison is case-insensitive betweem elements in phrase. The order of elements is important.

Sourceval compare_phrase : phrase compare

compare_phrase a b compares phrase a and phrase b semantically.

Sourceval equal_addr : addr equal

equal_addr a b tests if addr a and addr b are semantically equal. An IPv4 should be equal with an IPv6 address. Then, for extended kind, we strictly compare kind and value.

Sourceval compare_addr : addr compare

compare_addr a b compares addr a and addr b, we priotize IPv6, IPv4 and finally Ext.

Sourceval equal_domain : domain equal

equal_addr a b tests if domain a and domain b are semantically equal. We do not resolve domain, a `Domain could be semantically equal to another `Domain if they point to the same IPv4/IPv6.

Sourceval compare_domain : domain compare

comapre_domain a b compares domain a and domain b, we prioritize `Domain, `Literal and finally `Addr. The comparison between two `Literal and between part of `Domain are case-insensitive.

Sourceval equal_domains : (domain * domain list) equal

equal_domains a b apply equal_domain to ordered domains (see compare_domain) between a and b.

Sourceval compare_domains : (domain * domain list) compare

compare_domains a b compares ordered list of domain a and ordered list of domain b.

Sourceval equal_local : ?case_sensitive:bool -> local equal

equal_local ?case_sensitive a b tests if local a and local b are semantically equal. Standards notices local-prt SHOULD be case-sensitive, the client can choose this behaviour with case_sensitive.

Sourceval compare_local : ?case_sensitive:bool -> local compare

compare_local ?case_sensitive a b compares local a and local b semantically. The user can decide if the comparison is case-sensitive or not (with case_sensitive).

Sourceval equal_mailbox : ?case_sensitive:bool -> mailbox equal

equal_mailbox ?case_sensitive a b tests if mailbox a and mailbox b are semantically equal. The user can define if the local-part need to be case-sensitive or not (by case_sensitive). If a xor b has a name, we cosider a = b if we have the same local-part and same domain(s).

Sourceval compare_mailbox : ?case_sensitive:bool -> mailbox compare

compare ?case_sensitive a b compares mailbox a and mailbxo b semantically. We prioritize local-part, domain-part and finally optionnal name.

Sourceval compare_group : group compare

comapre_group a b compares group a and group b. We compare the group name first and compare ordered mailboxes list then.

Sourceval equal_group : group equal

equal_group a b tests if group a and group b are semantically equal. We compare first group name and ordered mailboxes list then.

Sourceval equal : t equal

equal a b tests semantically t a and t b.

Sourceval compare : t compare

compare a b compares t a and t b.

Sourceval strictly_equal : t equal

A structurally equal function on t.

Decoders

Sourcetype error = [
  1. | `Invalid of string * string list
  2. | `Incomplete
]
Sourceval pp_error : error Fmt.t
Sourcemodule List : sig ... end
Sourceval of_string_with_crlf : string -> (mailbox, error) result
Sourceval of_string : string -> (mailbox, error) result
Sourceval of_string_raw : string -> int -> int -> (mailbox * int, error) result
OCaml

Innovation. Community. Security.