package async_smtp
Module Async_smtp.SimplemailSource
include module type of Async_smtp_types.Email.Simple
with module Expert := Async_smtp_types.Email.Simple.Expert
module Email := Email_message_kernelmodule Mimetype = Email_message.Email.Simple.Mimetypeval sexp_of_t : t -> Sexplib0.Sexp.tval from : t -> Email_address.t optionval to_ : t -> Email_address.t list optionval cc : t -> Email_address.t list optionval subject : t -> string optionval id : t -> string optionval extract_body : ?content_type:Mimetype.t -> t -> string optionextract_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.
val extract_body_ext' :
accept:
((Mimetype.t * (string * string option) list) option -> 'format option) ->
t ->
('format * string) Core.Sequence.textract_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)
val extract_body_ext :
accept:
((Mimetype.t * (string * string option) list) option -> 'format option) ->
?order:('format -> 'format -> int) ->
t ->
('format * string) optionRelated 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):
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--
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.
val inline_parts : t -> Email_message_kernel.Simple.Content.t listFor parsing attachments. Use create ~attachments to add attachments. Convenience functions for email parts that have "Content-Disposition: attachment"
val create :
?from:Email_address.t ->
to_:Email_address.t list ->
?cc:Email_address.t list ->
?reply_to:Email_address.t ->
subject:string ->
?id:string ->
?in_reply_to:string ->
?date:Core.Time_float.t ->
?auto_generated:unit ->
?extra_headers:
(Email_message_kernel.Headers.Name.t * Email_message_kernel.Headers.Value.t)
list ->
?attachments:(attachment_name * Content.t) list ->
?no_tracing_headers:[ `Because_not_using_standard_email_infra ] ->
Content.t ->
tval create_utf8 :
?from:Email_address.t ->
to_:Email_address.t list ->
?cc:Email_address.t list ->
?reply_to:Email_address.t ->
subject:string ->
?id:string ->
?in_reply_to:string ->
?date:Core.Time_float.t ->
?auto_generated:unit ->
?extra_headers:
(Email_message_kernel.Headers.Name.t * Email_message_kernel.Headers.Value.t)
list ->
?attachments:(attachment_name * Content.t) list ->
?no_tracing_headers:[ `Because_not_using_standard_email_infra ] ->
Content.t ->
tA unique value to be used in a Message-Id header
val all_attachments :
?include_inline_parts:[ `None | `Named | `Named_or_has_content_id ] ->
?look_through_attached_mails:bool ->
t ->
Attachment.t listall_attachments looks recursively through the e-mail parts, looking for attachments.
~include_inline_parts (default is `None) controls whether this function will attempt to interpret inline parts as attachments. `Named_or_has_content_id most aggressively classifies parts as attachments, including inline parts that are either named or have a Content-Id header. `Named will include inline parts that are named.
If ~look_through_attached_mails:true (the default), it will separately include both e-mail attachments as well as the attachments to those e-mails. Otherwise it will include e-mail attachments but not (separately) any of the attached e-mails' attachments.
val map_attachments :
?include_inline_parts:[ `None | `Named | `Named_or_has_content_id ] ->
t ->
f:(Attachment.t -> [ `Keep | `Replace of t ]) ->
tmap_attachments recurses into message/rfc822 parts. However, if a message/rfc822 part is replaced, there is no further recursion.
val send' :
?log:Async.Log.t ->
?credentials:Async_smtp__.Credentials.elt list ->
?server:Core.Host_and_port.t ->
?from:Async_smtp_types.Email_address.t ->
?sender_args:Async_smtp_types.Smtp_envelope.Sender_argument.t list ->
to_:Async_smtp_types.Email_address.t list ->
?cc:Async_smtp_types.Email_address.t list ->
?bcc:Async_smtp_types.Email_address.t list ->
?reply_to:Async_smtp_types.Email_address.t ->
?bounce_to:Async_smtp_types.Email_address.t ->
subject:string ->
?id:string ->
?in_reply_to:string ->
?date:Core.Time_float.t ->
?auto_generated:unit ->
?extra_headers:
(Async_smtp_types.Email_headers.Name.t
* Async_smtp_types.Email_headers.Value.t)
list ->
?attachments:(attachment_name * Async_smtp_types.Email.Simple.Content.t) list ->
?no_tracing_headers:[ `Because_not_using_standard_email_infra ] ->
Async_smtp_types.Email.Simple.Content.t ->
Envelope_status.t Async.Deferred.Or_error.tval send :
?log:Async.Log.t ->
?credentials:Async_smtp__.Credentials.elt list ->
?server:Core.Host_and_port.t ->
?from:Async_smtp_types.Email_address.t ->
?sender_args:Async_smtp_types.Smtp_envelope.Sender_argument.t list ->
to_:Async_smtp_types.Email_address.t list ->
?cc:Async_smtp_types.Email_address.t list ->
?bcc:Async_smtp_types.Email_address.t list ->
?reply_to:Async_smtp_types.Email_address.t ->
?bounce_to:Async_smtp_types.Email_address.t ->
subject:string ->
?id:string ->
?in_reply_to:string ->
?date:Core.Time_float.t ->
?auto_generated:unit ->
?extra_headers:
(Async_smtp_types.Email_headers.Name.t
* Async_smtp_types.Email_headers.Value.t)
list ->
?attachments:(attachment_name * Async_smtp_types.Email.Simple.Content.t) list ->
?no_tracing_headers:[ `Because_not_using_standard_email_infra ] ->
Async_smtp_types.Email.Simple.Content.t ->
unit Async.Deferred.Or_error.t