Documentation
¶
Overview ¶
Package smtp sends mail over SMTP with the whole exchange bounded by a context.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SendMail ¶
func SendMail(ctx context.Context, addr string, auth smtp.Auth, from string, to []string, msg []byte) error
SendMail sends msg from from to each address in to via the SMTP server at addr, which must include a port. It's the equivalent of smtp.SendMail, except the whole exchange is bounded by ctx: if ctx is done before the message is sent, the connection is closed and ctx's error is returned. ctx should normally carry a deadline, as nothing else stops a server that stops responding.
The connection is upgraded with STARTTLS if the server offers it, verifying the server's certificate against addr's host. If auth is non-nil the server must offer AUTH, and auth is used to authenticate; if it's nil, no authentication is attempted.
Once the server has accepted the message, it counts as sent: if the QUIT that follows fails, or ctx is done before it completes, the failure is logged and SendMail returns nil so that a retry doesn't deliver the message again.
Types ¶
This section is empty.