LOGIN auth mechanism with ocamlnet?

ocamlnet

#1

I’m trying to use ocamlnet to send e-mails through smtp.office365.com.

I’m not sure how to use the “LOGIN” auth mechanism with ocamlnet?

Should I write a LOGIN Netsys_sasl_types.SASL_MECHANISM module for this?

Here is what I did so far:

utop[54]> Nettls_gnutls.init ()
- : unit = ()
utop[55]> let provider = Netsys_crypto.current_tls()
val provider : (module Netsys_crypto_types.TLS_PROVIDER) = <module>
utop[56]> let tls_config = Netsys_tls.create_x509_config ~system_trust:true ~peer_auth:`Required provider
val tls_config : (module Netsys_crypto_types.TLS_CONFIG) = <module>
utop[57]> let conn = new Netsmtp.connect (`Socket (`Sock_inet_byname(Unix.SOCK_STREAM, "smtp.office365.com", 587), Uq_client.default_connect_options) ) 30.;;
val conn : Netsmtp.connect = >obj>
utop[58]> conn#helo ();;
- : string list =
["PR0P264CA0006.outlook.office365.com Hello [88.184.200.161]";
"SIZE 157286400"; "PIPELINING"; "DSN"; "ENHANCEDSTATUSCODES"; "STARTTLS";
"8BITMIME"; "BINARYMIME"; "CHUNKING"; "SMTPUTF8"]
utop[59]> conn#starttls ~peer_name:(Some "smtp.office365.com") tls_config
- : unit = ()
utop[60]> conn#helo ()
- : string list =
["PR0P264CA0006.outlook.office365.com Hello [88.184.200.161]";
"SIZE 157286400"; "PIPELINING"; "DSN"; "ENHANCEDSTATUSCODES";
"AUTH LOGIN XOAUTH2"; "8BITMIME"; "BINARYMIME"; "CHUNKING"; "SMTPUTF8"]
utop[62]> conn#helo_response |> Netsmtp.auth_mechanisms
- : string list = ["LOGIN"; "XOAUTH2"]

Thank you for any hint.