Documentation
¶
Overview ¶
Package mail sends the application's email through the provider the administrators configure; SMTP is the one provider. It also holds the default subjects and HTML templates of the notification emails, which the stored configuration falls back to.
Index ¶
Constants ¶
const ( DefaultEmailVerifySubject = "Verification code" DefaultExpirationEmailSubject = "Subscription Expired" DefaultMaintenanceEmailSubject = "系统维护通知 / System Maintenance Notice" DefaultTrafficExceedEmailSubject = "Subscription Traffic Exceed" )
Default subjects of the operator-configurable notification emails. Queue producers fall back to them when the admin config leaves the matching subject empty, which keeps existing deployments unchanged.
const ( DefaultEmailVerifyTemplate = `` /* 3033-byte string literal not displayed */ DefaultMaintenanceEmailTemplate = `` /* 2652-byte string literal not displayed */ DefaultExpirationEmailTemplate = `` /* 2270-byte string literal not displayed */ DefaultTrafficExceedEmailTemplate = `` /* 2083-byte string literal not displayed */ )
Default HTML templates of the notification emails, which the stored configuration falls back to like the subjects above. They are Go templates, bilingual in Chinese and English.
Variables ¶
This section is empty.
Functions ¶
func GetSupportedPlatforms ¶
func GetSupportedPlatforms() []integration.Info
GetSupportedPlatforms describes the providers and their configuration fields for the administrators' settings page.
Types ¶
type Platform ¶
type Platform int
Platform is an email provider, stored in the configuration by its name.
type SMTPClient ¶
type SMTPClient struct {
// contains filtered or unexported fields
}
SMTPClient sends through an SMTP relay, one connection per message.
func NewSMTPClient ¶
func NewSMTPClient(conf *SMTPConfig) *SMTPClient
NewSMTPClient returns a client for conf, or nil for a nil conf.
func (*SMTPClient) SendContext ¶ added in v1.21.0
SendContext delivers the message over one SMTP conversation, bounded by ctx and by the client's own deadline. When ctx ends the conversation the error matches ctx's error; when the relay outlasts the client's deadline it is an ordinary delivery failure.
type SMTPConfig ¶
type SMTPConfig struct {
Host string `json:"host"`
Port int `json:"port"`
User string `json:"user"`
Pass string `json:"pass"`
From string `json:"from"`
ReplyTo string `json:"reply_to"`
// SSL requires encryption: implicit TLS on port 465 or with ImplicitTLS,
// STARTTLS otherwise, refusing a relay that does not offer it. Unset,
// STARTTLS stays opportunistic and a relay without TLS is used in the
// clear.
SSL bool `json:"ssl"`
SiteName string `json:"siteName"`
// ImplicitTLS starts the connection with a TLS handshake (SMTPS) on a
// port other than 465, which is implicit TLS by definition. The relay and
// submission ports (25, 587, 2525) start in plaintext and upgrade through
// STARTTLS, so they never need it.
ImplicitTLS bool `json:"implicit_tls"`
// InsecureSkipVerify accepts any server certificate. It exists only for
// relays with self-signed certificates and must be set explicitly in the
// stored platform config; certificates are verified by default.
InsecureSkipVerify bool `json:"insecure_skip_verify"`
}
SMTPConfig is the stored configuration of the SMTP provider; SiteName, the sender's display name, comes from the site settings instead.
type Sender ¶
type Sender interface {
// SendContext delivers an HTML body to the recipients. ctx bounds the
// whole delivery; the provider applies its own deadline besides.
SendContext(ctx context.Context, to []string, subject, body string) error
}
Sender delivers email through one provider account. It is safe for concurrent use.