package async_smtp

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

This module provides helpers for writing expect tests for testing Async_smtp and Async_smtp.Server plugins.

type 'a smtp_flags = ?tls:bool -> 'a
type 'a server_flags = ?max_message_size:Core.Byte_units.t -> ?malformed_emails:[ `Reject | `Wrap ] -> ?echo_delivery:bool -> ?server_log:[ Async.Log.Level.t | `None ] -> ?plugin:(module Async_smtp__.Server_plugin.S) -> ?plugin_log:[ Async.Log.Level.t | `None ] -> 'a
type 'a client_flags = ?credentials:Async_smtp__.Credentials.elt list -> ?client_greeting:string -> ?client_log:[ Async.Log.Level.t | `None ] -> 'a
val envelope : ?sender:string -> ?recipients:string list -> ?data:string -> unit -> Async_smtp_types.Smtp_envelope.t

Helper for creating SMTP Envelopes

Attempt to send the given envelope to a dummy server. Expect test output will be the SMTP session transcript with the following format: < EHLO Client > 200 Server Response Custom plugin output

val manual_client : ((client:(string -> unit Async.Deferred.t) -> server:(string -> unit Async.Deferred.t) -> unit Async.Deferred.t) -> unit Async.Deferred.t) server_flags smtp_flags

Like smtp but instead of the mailcore client you describe the client behaviour allowing testing server behaviour in edge cases.

Use client to submit requests to the server, and server to document the expected responses.

Example

manual_client
  (fun ~client ~server ->
     server "220 [SMTP TEST SERVER]"
     >>= fun () ->
     client "EHLO test"
     >>= fun () ->
     server "250-Ok: Continue, extensions follow:\n\
             250 8BITMIME"
     >>= fun () ->
     client "RESET"
     >>= fun () ->
     server "250 Ok: continue"
     >>= fun () ->
     client "QUIT"
     >>= fun () ->
     server "221 closing connection"
  )
val manual_server : (Async_smtp_types.Smtp_envelope.t list -> (client:(string -> unit Async.Deferred.t) -> server:(string -> unit Async.Deferred.t) -> unit Async.Deferred.t) -> unit Async.Deferred.t) client_flags smtp_flags

Like manual_client but you provide the server side of the protocol.

Use client to document expected requests, and server to send the responses.