Documentation
¶
Overview ¶
Package mailtest is an in-process SMTP server for tests of onemailer and the code that uses it: plain, STARTTLS or implicit TLS, optional AUTH PLAIN, and scripted failures. It listens on 127.0.0.1 only.
srv := mailtest.Start(t, mailtest.Options{Mode: mailtest.StartTLS})
cfg = cfg.WithRootCAs(srv.Roots) // with SMTP_HOST=srv.Host, SMTP_PORT=srv.PortString()
// … send …
got := srv.Messages()
Index ¶
Constants ¶
const ( Plain = "plain" // no TLS offered StartTLS = "starttls" // STARTTLS offered Implicit = "tls" // TLS from the first byte )
Modes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
Mode string
// CertHost is the name in the certificate; default "localhost" (with the
// IP 127.0.0.1). Another name makes verification fail.
CertHost string
// Username and Password, when set, are required.
Username, Password string
// AuthMechs are the AUTH mechanisms offered: "PLAIN" and/or "LOGIN";
// default PLAIN.
AuthMechs []string
// FailData makes the first FailData DATA commands answer 451.
FailData int
// RejectRcpt makes RCPT TO answer 550.
RejectRcpt bool
}
Options configure a server.
type Server ¶
type Server struct {
Host string
Port int
// Roots trusts the server's certificate.
Roots *x509.CertPool
// contains filtered or unexported fields
}
Server is a running test server.
func (*Server) PortString ¶
PortString returns the port as a string, for an {PREFIX}SMTP_PORT setting.