Documentation
¶
Overview ¶
Package mailer sends email: the summary email. It is the only package that speaks SMTP. The in-memory fake for tests is in mailer/mailertest.
Index ¶
Constants ¶
View Source
const ( StartTLS = "starttls" Implicit = "implicit" NoTLS = "none" )
TLS modes, as config.SMTPTLS spells them.
Variables ¶
View Source
var ( // ErrAuth means the mail server refused the user name or password. ErrAuth = errors.New("the mail server refused the user name or password") // ErrConnection means the mail server could not be reached, or the connection broke. ErrConnection = errors.New("could not reach the mail server") // ErrUnsupported means the server lacks what the settings require: STARTTLS, or a // sign-in method this package speaks. ErrUnsupported = errors.New("the mail server does not support what the settings require") // ErrTLS means the TLS handshake or the certificate check failed. ErrTLS = errors.New("the TLS handshake with the mail server failed") // ErrRefused means the server refused the sender, the recipient or the message. ErrRefused = errors.New("the mail server refused the email") // ErrAddress means an address in the message cannot be used. ErrAddress = errors.New("not a usable email address") )
Sentinel errors. SMTP wraps them, so callers test with errors.Is.
Functions ¶
Types ¶
type Message ¶
type Message struct {
To string // one address, with or without a display name
Subject string
Text string
HTML string
}
Message is one email to one recipient. HTML is optional; Text is always sent.
type SMTP ¶
type SMTP struct {
Addr string // host:port
TLS string // StartTLS, Implicit or NoTLS
Username string // empty = no sign-in
Password string
From string // the From header: an address, or "Name <address>"
// TLSConfig is copied for each connection, with ServerName set to the host when it is
// empty; nil checks the server's certificate against the system's roots.
TLSConfig *tls.Config
Timeout time.Duration // the whole send; 0 = 30 seconds
Now func() time.Time // the Date header; nil = time.Now
}
SMTP sends through one mail server. Credentials are used only on the wire.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mailertest is an in-memory mailer.Sender for tests of the packages that send email.
|
Package mailertest is an in-memory mailer.Sender for tests of the packages that send email. |
Click to show internal directories.
Click to hide internal directories.