Documentation
¶
Overview ¶
Package mailsettings stores the SMTP settings an owner saves in the admin. The password is sealed with the server secret; a missing row means the server's SMTP_* environment applies.
Index ¶
Constants ¶
const ( ProviderCustom = "custom" ProviderSES = "ses" ProviderGmail = "gmail" )
Providers (presets). The preset decides the host for SES and Gmail.
const ( MaxHostLen = 253 MaxUsernameLen = 255 MaxAddressLen = 254 MaxFromNameLen = 200 )
Field length limits.
const DefaultSESRegion = "us-east-1"
DefaultSESRegion is preselected for the Amazon SES preset.
const GmailHost = "smtp.gmail.com"
GmailHost is the SMTP host of the Gmail / Google Workspace preset.
Variables ¶
var Providers = []string{ProviderCustom, ProviderSES, ProviderGmail}
Providers lists the valid provider values.
var SESRegions = []string{
"us-east-1", "us-east-2", "us-west-1", "us-west-2",
"ca-central-1", "sa-east-1",
"eu-west-1", "eu-west-2", "eu-west-3", "eu-central-1", "eu-north-1", "eu-south-1",
"ap-south-1", "ap-northeast-1", "ap-northeast-2", "ap-northeast-3",
"ap-southeast-1", "ap-southeast-2",
}
SESRegions is the closed list of regions the SES preset offers.
Functions ¶
func IsLoopbackHost ¶
IsLoopbackHost reports whether host is one of the three names Go's smtp.PlainAuth accepts without TLS: "localhost", "127.0.0.1" and "::1", compared exactly (callers lower-case the host first). Security "none" is only accepted for these, so a wider rule would pass validation and then fail at AUTH.
func PasswordKey ¶
PasswordKey derives the key that seals the password from the server secret.
Types ¶
type Querier ¶
type Querier interface {
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
Exec(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error)
}
Querier is the part of a pgx pool the Store needs.
type Settings ¶
type Settings struct {
Provider string
SESRegion string // only for ProviderSES
Host string
Port int
Security email.Security
Username string
PasswordSealed []byte // sealed password; nil when none is saved
FromAddress string
FromName string // blank = follow the site name
UpdatedAt time.Time // set by the database
}
Settings is the saved SMTP configuration.
func (Settings) EmailConfig ¶
EmailConfig builds the service configuration for these settings with the opened password. Saved settings may use host "localhost".
func (Settings) HasPassword ¶
HasPassword reports whether a sealed password is stored.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store reads and writes the single hatamoto_smtp_settings row. It does not cache: it is read at boot, after each admin change and by the replica convergence check, never per request.