netio/smtp.rs#
Source: lib/netio/smtp.rs
smtp -- sending mail (RFC 5321) for notifications
send(&SmtpConfig, &Mail) -> Result<String, String> the server's final answer or the
reason it failed (German, for people)
Security::StartTls (port 587) / Tls (465) / None (25; plain to any server, e.g. a relay
inside a network, and refuses to authenticate in clear: with a user name it is an error)
AUTH PLAIN or LOGIN (whatever the server offers; PLAIN first)
message(&Mail, host, now) -> the RFC 5322 text: UTF-8 subject as an encoded word, the body
text/plain (and text/html as multipart/alternative) in base64, Date and Message-ID
TLS checks the server like a browser (the system's certificate authorities, plus extra CAs
for a company's own); after STARTTLS nothing the server sent before the switch is used
(no command injection across the switch).
enum SecurityStartTlsTlsNone
impl Security
fn parse(s: &str) -> Securityfn default_port(self) -> u16struct SmtpConfighost: Stringport: u16security: Securityusername: Stringpassword: Stringhelo: String-- our name in EHLOextra_cas: Vec<Cert>-- CAs trusted in addition to the system'stimeout_ms: u32
struct Mailfrom: Stringto: Vec<String>subject: Stringtext: Stringhtml: String-- an HTML alternative (optional)
fn send(cfg: &SmtpConfig, mail: &Mail) -> Result<String, String>send one messagefn rfc5322_date(t: i64) -> String"Tue, 13 Oct 2026 15:04:05 +0000"fn message(mail: &Mail, host: &str, now: i64) -> Stringthe message text (CRLF line ends)