Library
Module
Module type
Parameter
Class
Class type
Emile module, parser of e-mail address.
The local part of an e-mail address is composed by two kinds of words:
`Atom
is string as is.`String
is a string surrounded by double-quote to allow white-space.The second kind is sanitized — we deleted double-quote which surround string
.
type local = word list
Local part of e-mail address.
Subset of domain described by RFC5321 which contains 3 kinds of address:
IPv4
: a valid IPv4 addressIPv6
: a valid IPv6 addressExt (ldh, value)
: an extended kind of domain recognized by ldh
identifier which valus is value
Parser of IPv4
and IPv6
was done by Ipaddr
. An extended kind Ext
needs to be resolved by the client.
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.
A phrase is a sentence to associate a name with an e-mail address or a group of e-mail addresses. `Encoded
value is not normalized on the charset specified. The encoded's string is decoded as is only. For example, `Encoded
can inform to use KOI-8 encoding (cyrillic charset). However, Emile
does not check if value is a valid KOI-8 string, nor normalizes to unicode. Emile
just decodes it as is.
type 'a fmt = Format.formatter -> 'a -> unit
Alias of String.compare
.
case_insensitive a b
maps values with lowercase_ascii
and compare them with String.compare
. We do not map UTF8 value.
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 (Pervasives.compare
) kind and value.
equal_domains a b
apply equal_domain
to ordered domains (see compare_domain
) between a
and b
.
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 consider a = b
if we have the same local-part and same domain(s). Otherwise, we compare identifier/phrase
between them.
compare ?case_sensitive a b
compares mailbox
a
and mailbxo
b
semantically. We prioritize local-part, domain-part and finally optionnal name.
If you don't want a headache, you should move on.
module Parser : sig ... end
This is an aggregation of rules used to parse an e-mail address. The goal of this documentation is to show relations between RFCs, updates, and final description of parts needed to parse an e-mail address.
module List : sig ... end
address_of_string_with_crlf s
parses s
which have the form: local@domain
. Named email or multiple-domain email are not handle by this parser. s
must terminate with CRLF
as the delimiter. If the parser fails, it return an error error
.
address_of_string s
parses s
which have the form: local@domain
. Named email or multiple-domain email are not handle by this function. If the parser fails, it return an error error
. It's possible that address_of_string
did not consume all s
.
val address_of_string_raw :
off:int ->
len:int ->
?tmp:Bigstringaf.t ->
string ->
(int * address, [> error ]) result
address_of_string_raw s off len
parses a sub-part of s
starting at off
and it computes at most len
bytes. It returns the email and how many bytes it consumes. Named email or multiple-domain are not handle by this parser. If the parser fails, it return an error error
.
If the user has an already allocated Bigstringaf.t
, it can use it as an internal buffer to parse given input s
.
val set_of_string_raw :
off:int ->
len:int ->
?tmp:Bigstringaf.t ->
string ->
(int * t, [> error ]) result
of_string_with_crlf s
parses s
which can have multiple form:
Bobby <bobby@mail.net>
<@laposte.net:bobby@mail.net
bobby@mail.net
<bobby@mail.net>
About named email, the parser handles encoded-word (according RFC 2047) to be able to use a special charset (like UTF-8) to show the name. Parser decodes encoded-word as is and do not do any translation from charset specified to any encoding (eg. translation from latin1 to UTF-8).
s
must terminates with CRLF
as the delimiter. If the parser fails, it return an error error
.
of_string s
is of_string_with_crlf
but did not need CRLF
at the end. It's possible that of_string
did not consume all s
.
val of_string_raw :
off:int ->
len:int ->
?tmp:Bigstringaf.t ->
string ->
(int * mailbox, [> error ]) result
of_string_raw s off len
is of_string_with_crlf
but did not need CRLF
at the end. It parses only a sub-part of s
starting at off
and computes at most len
bytes. It returns how many bytes it consumed.
If the user has an already allocated Bigstringaf.t
, it can use it as an internal buffer to parse given input s
.
val to_string : mailbox -> string
to_string mailbox
returns a well-formed string which represents the given mailbox
value.