Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Host string // SMTP_HOST (default "localhost")
Port int // SMTP_PORT (default 1025)
User string // SMTP_USER (default "" -- a local catcher like maildev needs no auth)
Pass string // SMTP_PASS (default "")
From string // SMTP_FROM (default "no-reply@example.com")
TLS bool // SMTP_TLS (default false, matching a plaintext local catcher)
// TLSInsecure skips STARTTLS certificate verification (SMTP_TLS_INSECURE,
// default false). The connection is still encrypted, just not
// cert-verified. Only set true for a trusted relay with a non-standard
// certificate.
TLSInsecure bool
}
Config is the resolved SMTP configuration consumed by SMTPTransport. Build it with LoadConfig, which reads SMTP_* from the environment with maildev-friendly defaults, or construct it directly.
func LoadConfig ¶
func LoadConfig() Config
LoadConfig reads SMTP_* env vars with local-catcher (e.g. maildev) defaults: host localhost, port 1025, no user/pass, From no-reply@example.com, no TLS.
type SMTPTransport ¶
type SMTPTransport struct {
// contains filtered or unexported fields
}
SMTPTransport is an email.Transport backed by net/smtp. With no SMTP_USER and no TLS configured (the default, matching a local catcher like maildev) it does a bare, unauthenticated handshake; otherwise it STARTTLS-upgrades and/or authenticates against a real relay.
func NewSMTPTransport ¶
func NewSMTPTransport(cfg Config) *SMTPTransport
NewSMTPTransport returns an SMTPTransport for the given Config.
func (*SMTPTransport) Send ¶
Send renders m via m.Bytes and delivers it to m.Recipients() (the To ∪ Cc ∪ Bcc set) using the SMTP envelope MAIL FROM of m.EnvelopeFrom, falling back to m.From when EnvelopeFrom is unset. Bcc addresses are only ever used for RCPT TO -- m.Bytes never writes them into the message headers.