Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · smtp

Docs

std/smtp

On this page

Index

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).

Source: std/smtp.xo:10

SmtpErr.display

fn (e: SmtpErr) display() -> Str

CODE MSG (net/textproto’s Error), or MSG alone for code 0 (decision 0358).

Source: std/smtp.xo:16

Auth

enum Auth {
  None
  Plain(user: Str, password: Secret[Str])
  CramMd5(user: Str, secret: Secret[Str])
}

How the client authenticates (net/smtp PlainAuth, CRAMMD5Auth).

Source: std/smtp.xo:19

Security

enum Security {
  StartTls
  Tls
  None
} derive Display

The 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.

Source: std/smtp.xo:29

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.dial

Sends 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.

Source: std/smtp.xo:41

↑ index