Documentation
¶
Index ¶
- Variables
- func ParseEmailAddress(email string) (*mail.Address, error)
- func ParseEmailTemplates(files, subjects map[string]string, defaultLanguage string) (map[string]*template.Template, error)
- func VerifyMXRecord(email string) error
- func WriteError(w http.ResponseWriter, err error)
- type DB
- func (db *DB) EmailRevalidation(ctx context.Context) bool
- func (db *DB) ExecCountContext(ctx context.Context, query string, args ...any) (int64, error)
- func (db *DB) ExecUserContext(ctx context.Context, query string, args ...any) error
- func (db *DB) QueryIterateContext(ctx context.Context, query string, f func(rows *sql.Rows) error, args ...any) error
- func (db *DB) QueryScanContext(ctx context.Context, query string, results []any, args ...any) error
- func (db *DB) QueryUserContext(ctx context.Context, query string, results []any, args ...any) error
- type DNSResolver
- type EmailConfiguration
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ParseEmailAddress ¶
ParseEmailAddress parses a single RFC 5322 address, e.g. "Barry Gibbs <bg@example.com>"
func ParseEmailTemplates ¶
func VerifyMXRecord ¶
VerifyMXRecord checks if the given email address has a valid MX record. If none is found, it alternatively looks for a valid A or AAAA record as this is used as fallback by mailservers (implicit MX per RFC 5321 Section 5.1).
It distinguishes a permanent failure (the domain does not exist) from a transient one (no network, DNS timeout, server misbehaving): the former returns ErrInvalidEmailDomain so the address is not retried on every run, while the latter returns ErrNoNetwork so it is retried later.
func WriteError ¶
func WriteError(w http.ResponseWriter, err error)
Types ¶
type DB ¶
func (*DB) EmailRevalidation ¶
EmailRevalidation returns whether email address revalidation is enabled.
func (*DB) ExecCountContext ¶
func (*DB) ExecUserContext ¶
func (*DB) QueryIterateContext ¶
func (*DB) QueryScanContext ¶
type DNSResolver ¶
type DNSResolver interface {
LookupMX(host string) ([]*net.MX, error)
LookupIP(host string) ([]net.IP, error)
}
DNSResolver is an interface for DNS lookups, allowing injection of test doubles.
var DefaultDNSResolver DNSResolver = netDNSResolver{}
DefaultDNSResolver is the default DNS resolver used by VerifyMXRecord.
type EmailConfiguration ¶
type EmailConfiguration struct {
EmailServer string `json:"email_server" mapstructure:"email_server"`
EmailHostname string `json:"email_hostname" mapstructure:"email_hostname"`
EmailFrom string `json:"email_from" mapstructure:"email_from"`
DefaultLanguage string `json:"default_language" mapstructure:"default_language"`
EmailAuth smtp.Auth
}
func (EmailConfiguration) SendEmail ¶
func (conf EmailConfiguration) SendEmail( templates map[string]*template.Template, subjects map[string]string, templateData map[string]string, to []string, lang string, ) error
SendEmail sends a templated email to the supplied email address(es). When multiple recipients are specified, the email is sent as a BCC email.
func (EmailConfiguration) TranslateString ¶
func (conf EmailConfiguration) TranslateString(strings map[string]string, lang string) string
func (EmailConfiguration) VerifyEmailServer ¶
func (conf EmailConfiguration) VerifyEmailServer() error