Module Async_smtp.Spool

module Message_id : Core.Identifiable
type t
val create : config:Server_config.t ‑> log:Mail_log.t ‑> unit ‑> t Async.Deferred.Or_error.t

Lock the spool directory and load all the files that are already present there. Note that for the purposes of locking, the spool directory assumed to NOT be on an NFS file system.

val add : t ‑> flows:Mail_log.Flows.t ‑> original_msg:Types.Envelope.t ‑> Types.Envelope_with_next_hop.t list ‑> Types.Envelope.Id.t Async.Deferred.Or_error.t

Immediately write the message to disk and queue it for sending. The Envelope_with_next_hop.t list represents the different "sections" of one message. We make no guarantees about the order of delivery of messages.

val quarantine : t ‑> reason:string ‑> flows:Mail_log.Flows.t ‑> original_msg:Types.Envelope.t ‑> Types.Envelope_with_next_hop.t list ‑> unit Async.Deferred.Or_error.t
val kill_and_flush : ?timeout:unit Async.Deferred.t ‑> t ‑> [ `Finished | `Timeout ] Async.Deferred.t

kill_and_flush ~timeout t makes sure no new delivery sessions are being started and waits until all the currently running sessions have finished (returning when this is successful or when timeout becomes determined). It will not affect frozen messages or those waiting for retry intervals to elapse.

val set_max_concurrent_jobs : t ‑> int ‑> unit

The call set_max_concurrent_jobs t n does not affect delivery sessions that are already running. Of all the sessions that are started after this call only n will be allowed to run in parallel.

val freeze : t ‑> Message_id.t list ‑> unit Async.Deferred.Or_error.t
module Send_info : sig ... end
val send : ?retry_intervals:Core.Time.Span.t list ‑> t ‑> Send_info.t ‑> unit Async.Deferred.Or_error.t
val remove : t ‑> Message_id.t list ‑> unit Async.Deferred.Or_error.t
module Recover_info : sig ... end
val recover : t ‑> Recover_info.t ‑> unit Async.Deferred.Or_error.t
module Spooled_message_info : sig ... end
module Status : sig ... end
val status : t ‑> Status.t

This is not necessarily a snapshot of the spool at any given point in time. The only way to obtain such a snapshot would be to pause the server and we don't want to do that. However, this status will include emails that are stuck on the spool, and those are the ones we care about.

You should not try to work out the total number of unsent messages by counting the messages in the status. You should use the count_from_disk function instead.

val status_from_disk : Server_config.t ‑> Status.t Async.Deferred.Or_error.t

This is not necessarily a snapshot of the spool at any given point in time. The only way to obtain such a snapshot would be to pause the server and we don't want to do that. However, this status will include emails that are stuck on the spool, and those are the ones we care about.

You should not try to work out the total number of unsent messages by counting the messages in the status. You should use the count_from_disk function instead.

val count_from_disk : Server_config.t ‑> int Core.Or_error.t Async.Deferred.t
module Event : sig ... end
val event_stream : t ‑> Event.t Async.Pipe.Reader.t