123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300open!CoremoduletypeMimetype=sigtypet=privatestring[@@derivingcompare,sexp_of]valtext:tvaltext_utf8:tvalhtml:tvalhtml_utf8:tvalpdf:tvaljpg:tvalpng:tvalcsv:tvalmultipart_mixed:tvalmultipart_related:tvalmultipart_alternative:tvalof_string:string->tvalequal:t->t->boolvalarg_type:tCommand.Arg_type.tvalfrom_filename:string->tvalfrom_extension:string->tvalto_extension:t->stringoptionvalguess_encoding:t->Octet_stream.Encoding.knownendmoduletypeContent=sigtypeattachment_namemoduleMimetype:Ttypet=privateEmail.t[@@derivingsexp_of]valof_email:Email.t->tvalcreate_custom:content_type:Mimetype.t->?encoding:Octet_stream.Encoding.known->?extra_headers:(Headers.Name.t*Headers.Value.t)list->string->tvalcreate:content_type:Mimetype.t->?encoding:Octet_stream.Encoding.known->?extra_headers:(Headers.Name.t*Headers.Value.t)list->string->t[@@deprecated"[since 2019-08] Renamed to [create_custom]"]valhtml_utf8:?encoding:Octet_stream.Encoding.known(** default: `Quoted_printable *)->?extra_headers:(Headers.Name.t*Headers.Value.t)list->string->tvalhtml:?encoding:Octet_stream.Encoding.known(** default: `Quoted_printable *)->?extra_headers:(Headers.Name.t*Headers.Value.t)list->string->t[@@deprecated"[since 2019-08] Please specify the charset, e.g. [html_utf8]"]valtext_utf8:?encoding:Octet_stream.Encoding.known(** default: `Quoted_printable *)->?extra_headers:(Headers.Name.t*Headers.Value.t)list->string->tvaltext:?encoding:Octet_stream.Encoding.known(** default: `Quoted_printable *)->?extra_headers:(Headers.Name.t*Headers.Value.t)list->string->t[@@deprecated"[since 2019-08] Please specify the charset, e.g. [text_utf8]"](** Plain text e-mail that also includes an html version so it's displayed
monospace in gmail.
By default, we add some custom styling to disable the line-wrap formatting rule
which gmail uses. To disable this behavior, supply [~force_no_line_wrap:false].
*)valtext_monospace_utf8:?extra_headers:(Headers.Name.t*Headers.Value.t)list->?force_no_line_wrap:bool(** default: true *)->string->tvaltext_monospace:?extra_headers:(Headers.Name.t*Headers.Value.t)list->?force_no_line_wrap:bool(** default: true *)->string->t[@@deprecated"[since 2019-08] Please specify the charset, e.g. [text_monospace_utf8]"](** Combine 2 or more contents as alternative versions.
List should be sorted from worst to best. *)valalternatives:?extra_headers:(Headers.Name.t*Headers.Value.t)list->tlist->t(** Combine 2 or more contents that should be bundled together *)valmixed:?extra_headers:(Headers.Name.t*Headers.Value.t)list->tlist->t(** Add related resources (e.g. inline images).
You can reference them using 'cid:${attachment_name}' in the content.
To attach files you should use [create ~attachments] *)valwith_related:?extra_headers:(Headers.Name.t*Headers.Value.t)list->resources:(attachment_name*t)list->t->tvalcontent_type:t->Mimetype.t(** The Content-ID of the content *)valrelated_part_cid:t->attachment_nameoptionvalall_related_parts:t->(attachment_name*t)listvalfind_related:t->attachment_name->toption(** [content] and [parts] return [None] if the email doesn't properly parse. They also
return [None] if the message has content type "message/rfc822" *)valcontent:t->Octet_stream.toptionvalparts:t->tlistoption(** Get the alternative versions available. If the message is not of content type
"multipart/alternative" then return a singleton list. *)valalternative_parts:t->tlist(** Get the 'inline' parts, This expands "Content-Type: multipart/{mixed,related}",
stripping out any attachment parts. multipart/alternative is not expanded *)valinline_parts:t->tlistvalcontent_disposition:t->[`Inline|`Attachmentofstring]valattachment_name:t->stringoptionendmoduletypeExpert=sigtypettypeattachment_namemoduleMimetype:TmoduleContent:Tvalcreate_raw:from:string(** defaults to <user@host> *)->to_:stringlist->?cc:stringlist->?reply_to:string->subject:string->id:string->?in_reply_to:string->date:string->?auto_generated:unit->?extra_headers:(Headers.Name.t*Headers.Value.t)list->?attachments:(attachment_name*Content.t)list->Content.t->tvalcontent:normalize_headers:Headers.Normalize.encode->extra_headers:(Headers.Name.t*Headers.Value.t)list->encoding:Octet_stream.Encoding.known->string->tvalmultipart:normalize_headers:Headers.Normalize.encode->content_type:Mimetype.t->extra_headers:(Headers.Name.t*Headers.Value.t)list->tlist->tendmoduletypeStable=sigmoduleContent:sigtypelatestmoduleV1:sigtypet=latest[@@derivingbin_io,sexp]endendmoduleMimetype:sigtypelatestmoduleV1:Stable_without_comparatorwithtypet=latestendendmoduletypeEmail_simple=sigmoduleMimetype:Mimetypetypeattachment_name=string[@@derivingsexp_of]moduleContent:ContentwithmoduleMimetype:=Mimetypeandtypeattachment_name:=attachment_nametypet=Email.t[@@derivingsexp_of]valcreate:from:Email_address.t(** defaults to <user@host> *)->to_:Email_address.tlist->?cc:Email_address.tlist->?reply_to:Email_address.t->subject:string->id:string->?in_reply_to:string->date_string:string->?auto_generated:unit->?extra_headers:(Headers.Name.t*Headers.Value.t)list->?attachments:(attachment_name*Content.t)list->Content.t->tvalfrom:t->Email_address.toptionvalto_:t->Email_address.tlistoptionvalcc:t->Email_address.tlistoptionvalsubject:t->stringoptionvalid:t->stringoption(** [extract_body ?content_type t] returns the body associated with the email part that
matches the [content_type] mimetype, or none if [t] does not contain a body or part of
type [content_type].
*)valextract_body:?content_type:Mimetype.t(** default: [Mimetype.text] *)->t->stringoption(** [extract_body_ext]
and [extract_body_ext'] Attempt to find the message body in the preferred format.
[accept] is used to select only content parts in a format that is supported. If a
multipart component is accepted by [accept], we do NOT recursively extract the body.
We do so otherwise.
[order] will be used to select the least part (by default the first part)
*)valextract_body_ext':accept:((Mimetype.t*(string*stringoption)list)option->'formatoption)->t->('format*string)Sequence.tvalextract_body_ext:accept:((Mimetype.t*(string*stringoption)list)option->'formatoption)->?order:('format->'format->int)->t->('format*string)option(** Related parts are those that are included in a multi-part message with a "Content-ID"
header. This content can be referenced by adding the "cid:" prefix and stripping the
enclosing '<' and '>'.
For example (from https://tools.ietf.org/html/rfc2392):
{v
From: foo1@bar.net
To: foo2@bar.net
Subject: A simple example
Mime-Version: 1.0
Content-Type: multipart/related; boundary="boundary-example-1"; type=Text/HTML
--boundary-example 1
Content-Type: Text/HTML; charset=US-ASCII
to the other body part, for example through a statement such as:
<IMG SRC="cid:foo4*foo1@bar.net" ALT="IETF logo">
--boundary-example-1
Content-ID: <foo4*foo1@bar.net>
Content-Type: IMAGE/GIF
Content-Transfer-Encoding: BASE64
R0lGODlhGAGgAPEAAP/////ZRaCgoAAAACH+PUNvcHlyaWdodCAoQykgMTk5
NSBJRVRGLiBVbmF1dGhvcml6ZWQgZHVwbGljYXRpb24gcHJvaGliaXRlZC4A
etc...
--boundary-example-1--
v}
Calling [all_related_parts] on this email would return a list of length one where the
[attachment_name] is "foo4*foo1@bar.net" for the single entry.
Related parts are often used for inline images. *)valall_related_parts:t->(attachment_name*Content.t)listvalfind_related:t->attachment_name->Content.toptionvalinline_parts:t->Content.tlistmoduleExpert:ExpertwithmoduleMimetype:=MimetypeandmoduleContent:=Contentandtypet:=tandtypeattachment_name:=attachment_namemoduleStable:StablewithtypeContent.latest:=Content.tandtypeMimetype.latest:=Mimetype.tend