package async_smtp

  1. Overview
  2. Docs
SMTP client and server

Install

Dune Dependency

Authors

Maintainers

Sources

v0.17.0.tar.gz
sha256=c416027c2537e22129f7049bf03ec3f867557d47b194d7e91d72c399fe656b27

doc/src/async_smtp/client_config.ml.html

Source file client_config.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
open Core
open Async
open Async_ssl.Std

module Tls = struct
  type t =
    { version : Ssl.Version.t option
    ; options : Ssl.Opt.t list option
    ; name : string option
    ; allowed_ciphers : [ `Secure | `Openssl_default | `Only of string list ]
    ; ca_file : string option
    ; ca_path : string option
    ; mode : [ `Required | `Always_try | `If_available ]
    ; certificate_mode : [ `Ignore | `Verify ]
    }
  [@@deriving sexp, fields ~getters]

  let default =
    { version = None
    ; options = None
    ; name = None
    ; allowed_ciphers = `Secure
    ; ca_file = None
    ; ca_path = None
    ; mode = `If_available
    ; certificate_mode = `Ignore
    }
  ;;
end

module Domain_suffix = String

type t =
  { greeting : string option [@sexp.option]
  ; tls : (Domain_suffix.t * Tls.t) list
  ; send_receive_timeout : [ `Default | `This of Time_float.Span.t ]
  ; final_ok_timeout : [ `Default | `This of Time_float.Span.t ]
  }
[@@deriving sexp]

let default =
  { tls = [ "", Tls.default ]
  ; greeting = None
  ; send_receive_timeout = `Default
  ; final_ok_timeout = `Default
  }
;;

let load_exn file = Sexp_macro.load_sexp file t_of_sexp >>| Or_error.ok_exn

let match_tls_domain t domain =
  List.find t.tls ~f:(fun (suffix, _) -> String.is_suffix domain ~suffix)
  |> Option.map ~f:snd
;;

let has_tls t = not (List.is_empty t.tls)

let send_receive_timeout t =
  match t.send_receive_timeout with
  | `This send_receive_timeout -> send_receive_timeout
  | `Default -> Time_float.Span.of_sec 300.
;;

let final_ok_timeout t =
  match t.final_ok_timeout with
  | `This final_ok_timeout -> final_ok_timeout
  | `Default -> Time_float.Span.scale (send_receive_timeout t) 2.
;;
OCaml

Innovation. Community. Security.