Up

Module type S

Signature

val session_connect : log:Mail_log.t -> session:Types.Session.t -> [
| `Accept of string
| `Disconnect of Types.Reply.t option
] Async.Std.Deferred.t

session_connect is called when a client first connects, before any messages are accepted.

`Accept greeting initiates a session state and sends the given greeting.

`Disconnect maybe_reply terminates the connection sending the given reply. disconnect is NOT called.

val session_helo : log:Mail_log.t -> session:Types.Session.t -> string -> [
| `Continue
| `Deny of Types.Reply.t
| `Disconnect of Types.Reply.t option
] Async.Std.Deferred.t

session_helo is called in response to initial handshakes (i.e. HELO or EHLO).

`Continue will update the session state.

`Deny reply will send the given reply but leave the session open.

`Disconnect maybe_reply will send the given reply and close the session (disconnect is not called)

val process_sender : log:Mail_log.t -> session:Types.Session.t -> Types.Sender.t -> [
| `Continue
| `Reject of Types.Reply.t
] Async.Std.Deferred.t

process_sender is called in the event of a "MAIL FROM" SMTP command.

`Continue creates an envelope that is filled in by subsequent commands.

`Reject reply will abort this message.

val process_recipient : log:Mail_log.t -> session:Types.Session.t -> sender:Types.Sender.t -> Types.Email_address.t -> [
| `Continue
| `Reject of Types.Reply.t
] Async.Std.Deferred.t

process_recipient is called in the event of a "RCPT TO" SMTP command. `Continue augments the envelope in the pipeline and passes it on to the next phase. `Reject reply pass through an unmodified envelope to the next phase, omitting this address from the recipients list.

val process_envelope : log:Mail_log.t -> session:Types.Session.t -> Types.Envelope.t -> [
| `Consume of string
| `Reject of Types.Reply.t
| `Quarantine of Types.Envelope_with_next_hop.t list * Types.Reply.t * string
] Async.Std.Deferred.t

Called after the message body has been received:

`Consume ok_msg will discard the message and return a successful response to the client. It should be used if this plugin has processed the message and does not intend to relay the message (or a response).

`Reject reply will discard the message and return an error reply to the client. It should be used when the plugin does not wish to process this message.

`Send envelopes_to_relay will spool the given envelopes for further sending and give a successful response, once these messages have been safely spooled.

`Quarantine (envelopes_to_quarantine, reply, reason) will save the given messages to a directory for manual inspection and pass through the given reply to the client. reason is used only internally to tell us what check failed.

val rpcs : unit Async.Std.Rpc.Implementation.t list