123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384openCoreopenAsyncopenAsync_smtpmoduleHost_and_port=structincludeHost_and_portletof_string~portstr=matchString.rsplit2~on:':'strwith|None->Host_and_port.create~host:str~port|Some(host,"")->Host_and_port.create~host~port|Some(host,port)->letport=Int.of_stringportinHost_and_port.create~host~port;;letinet_addressaddr=Tcp.Where_to_connect.of_host_and_portaddrendmoduleAddress=structletparamdest=letopenCommand.Let_syntaxin[%map_openletdest=destinHost_and_port.of_string~port:25dest];;letparam_anon=paramCommand.Param.(anon("HOST[:PORT]"%:string))letparam_server=paramCommand.Param.(flag"-server"(requiredstring)~doc:"HOST[:PORT] Address of SMTP server to connect to");;endmoduleSmtp_client_config=structincludeSmtp_client.Configletloadfile=Sexp.load_sexp_conv_exnfilet_of_sexpletdefault=lazy(tryload".js-smtp.sexp"with|_->(trylethome=Option.value(Sys.getenv"HOME")~default:"~"inload(home^/".js-smtp.sexp")with|_->default));;letparam=letopenCommand.Let_syntaxin[%map_openletconfig_file=flag"-smtp-config"(optionalFilename_unix.arg_type)~doc:"File with config for the mailcore smtp client (defaults to ./.js-smtp.sexp \
or ~/.js-smtp.sexp or system defaults)"inmatchconfig_filewith|None->Lazy.forcedefault|Someconfig_file->loadconfig_file];;endmoduleHex=structletto_hexdigest=letresult=Bytes.create(String.lengthdigest*2)inlethex="0123456789ABCDEF"infori=0toString.lengthdigest-1doletc=int_of_chardigest.[i]inBytes.setresult(2*i)hex.[clsr4];Bytes.setresult((2*i)+1)hex.[cland0xF]done;Bytes.unsafe_to_string~no_mutation_while_string_reachable:result;;end