std/smtp
On this page
Index
- type
SmtpErr- method
SmtpErr.display
- method
- type
Auth - type
Security - fn
send
Types
SmtpErr
struct SmtpErr {
code: Int
msg: Str
}A failed send: the server’s reply code and text (550 5.1.1 no such user), or code 0 for an error found before or outside a reply (a
connection error, a CR or LF in an address, smtp: server doesn't support STARTTLS).
SmtpErr.display
fn (e: SmtpErr) display() -> StrCODE MSG (net/textproto’s Error), or MSG alone for code 0 (decision 0358).
Auth
enum Auth {
None
Plain(user: Str, password: Secret[Str])
CramMd5(user: Str, secret: Secret[Str])
}How the client authenticates (net/smtp PlainAuth, CRAMMD5Auth).
Security
enum Security {
StartTls
Tls
None
} derive DisplayThe connection’s protection (decision 0290): StartTls requires the
server’s STARTTLS (the default); Tls is implicit TLS from the first
byte (port 465); None sends in plain text, allowed only to a
loopback host.
Functions
send
fn send(net: Net, addr: Str, from: Str, to: List[Str], msg: Bytes, auth: Auth = Auth.None, security: Security = Security.StartTls, roots: Bytes = b"", hello: Str = "localhost") -> () ! SmtpErr uses net.dialSends msg (the message’s bytes: headers, a blank line, the body; CRLF
or LF line endings) from from to every address of to through the
server at addr (host:port), as net/smtp.SendMail: the greeting,
EHLO (HELO when refused), STARTTLS with the server’s name verified
(against roots, a PEM bundle, when given; else the system roots), AUTH,
MAIL FROM, RCPT TO for each, DATA (dot stuffed, CRLF), QUIT.