package smtp

  1. Overview
  2. Docs
type 'a monad
type handle

Type of a handle to a SMTP connection.

type request = [
  1. | `Helo of string
  2. | `From of string
  3. | `To of string
  4. | `Data
  5. | `Msg_body of string
  6. | `Quit
]

Type of a request.

type response = [
  1. | `Ok of int * string
  2. | `Failure of int * string
]

Type of a response.

module Addr : sig ... end

Module for handling email addresses.

exception Negative_reply of int * string

Exception raised when the remote SMTP server returns a negative reply.

val connect : ?host:string -> ?port:string -> name:string -> unit -> handle monad

open ~host ~port is a promise of a handle to an open connection to the SMTP server located at host:port.

val close : handle -> unit monad

close h closes h, cleanly exiting the connection to the SMTP server if needed.

val request : handle -> request -> response monad

request h req sends req to the SMTP server handled by h.

val send : handle -> from:Addr.t -> to_:Addr.t list -> body:string -> response monad

send h ~from ~to_ ~body use the SMTP handled by h to send a mail of body ~body from address ~from to addresses ~to_.

val sendmail : ?host:string -> ?port:string -> name:string -> from:Addr.t -> to_:Addr.t list -> body:string -> unit -> response monad

sendmail ~host ~port ~from ~to_ ~body sends the mail of body ~body from address ~from to addresses ~to using the SMTP server at address host:port.

OCaml

Innovation. Community. Security.