package async_smtp

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

Source file smtp_extension.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
open! Core

let all_of_list _ = [ [] ]
let all_of_string = []

type t =
  | Start_tls
  | Auth of string list
  | Mime_8bit_transport
  | Other of string
[@@deriving compare, sexp, enumerate]

let equal = [%compare.equal: t]

let of_string str =
  let t =
    match String.uppercase str |> String.split ~on:' ' with
    | [ "STARTTLS" ] -> Start_tls
    | "AUTH" :: mechs ->
      mechs |> List.map ~f:String.strip |> List.filter ~f:(Fn.non String.is_empty) |> Auth
    | [ "8BITMIME" ] -> Mime_8bit_transport
    | _ -> Other str
  in
  t
;;

let to_string = function
  | Start_tls -> "STARTTLS"
  | Auth mechs -> String.concat ~sep:" " ("AUTH" :: mechs)
  | Mime_8bit_transport -> "8BITMIME"
  | Other str -> str
;;