Documentation
¶
Overview ¶
Package mail sends the panel's transactional e-mails (address verification, sign-in codes, password reset, test message) over SMTP with net/smtp: implicit TLS, STARTTLS or plain, PLAIN/LOGIN authentication, and multipart/alternative (text + minimal HTML) bodies.
Index ¶
Constants ¶
View Source
const ( LocaleEN = "en" LocaleRU = "ru" DefaultLocale = LocaleEN )
Locales with templates; anything else falls back to DefaultLocale.
Variables ¶
View Source
var ErrNotConfigured = errors.New("mail: SMTP is not configured")
ErrNotConfigured is returned when no SMTP host is set.
Functions ¶
func NormalizeLocale ¶
NormalizeLocale maps "ru-RU", "RU" etc. to a supported locale ("" when unsupported).
func Validate ¶
func Validate(cfg config.SMTPConfig) error
Validate checks the fields Send relies on.
Types ¶
type Data ¶
type Data struct {
// Title is the panel name (branding title).
Title string
Username string
// Code is the one-time code (verify_email, login_code).
Code string
// Link is the password reset link.
Link string
// Minutes is the validity of the code or link.
Minutes int
// IP is the client address that triggered the e-mail.
IP string
}
Data fills a template.
type Message ¶
type Message struct {
To string
Subject string
Text string
// HTML is optional; when set the body is multipart/alternative.
HTML string
}
Message is one e-mail to a single recipient.
type SMTP ¶
type SMTP struct {
Config config.SMTPConfig
// Now is the clock for the Date header (default time.Now).
Now func() time.Time
}
SMTP is a Sender for one server configuration.
func NewSMTP ¶
func NewSMTP(cfg config.SMTPConfig) *SMTP
NewSMTP returns a Sender delivering through cfg.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mailtest is an in-process fake SMTP server for tests: it speaks enough ESMTP (EHLO, STARTTLS, AUTH PLAIN/LOGIN, MAIL, RCPT, DATA) for net/smtp and records every accepted message.
|
Package mailtest is an in-process fake SMTP server for tests: it speaks enough ESMTP (EHLO, STARTTLS, AUTH PLAIN/LOGIN, MAIL, RCPT, DATA) for net/smtp and records every accepted message. |
Click to show internal directories.
Click to hide internal directories.