Documentation
¶
Overview ¶
Package config defines the mailctl YAML schema and loads it into a desired-state tree.
Index ¶
Constants ¶
const ( DefaultCloudflareBaseURL = "https://api.cloudflare.com/client/v4" DefaultPurelymailBaseURL = "https://purelymail.com" DefaultTTL = 1 // DefaultDMARCPct is applied when dmarc is configured but pct is omitted, // so pct is not a required key. DefaultDMARCPct = 100 )
const SchemaVersion = 1
SchemaVersion is the only config schema version this build understands.
Variables ¶
var InboundProviders = []string{"purelymail", "cfrouting", "ms365"}
InboundProviders accept inbound mail: each publishes MX records and creates its own alias routing rules. A domain may name at most one; cfsending is outbound-only and may pair with either.
var KnownProviders = []string{"purelymail", "cfrouting", "cfsending", "ms365"}
KnownProviders is every mail provider name the config accepts. Providers are registered at init time in internal/mail, but config must be able to reject a typo without importing that package, so the list is duplicated here deliberately and kept in sync by TestKnownProvidersMatchRegistry.
var MailboxlessProviders = []string{"cfrouting", "cfsending"}
MailboxlessProviders route mail but do not host it. A domain using only these providers may not declare mailboxes.
Functions ¶
Types ¶
type Alias ¶
type CloudflareConfig ¶
type Config ¶
type Config struct {
Version int `yaml:"version"`
Cloudflare CloudflareConfig `yaml:"cloudflare"`
Purelymail PurelymailConfig `yaml:"purelymail"`
Domains []Domain `yaml:"domains"`
}
func Load ¶
Load reads path, expands ${VAR} references using getenv, applies defaults, and validates the result. getenv may be nil, in which case os.Getenv is used.
func (*Config) ApplyDefaults ¶
func (c *Config) ApplyDefaults()
ApplyDefaults sets default values for configuration fields that are not explicitly set.
type Deliverability ¶
type Deliverability struct {
SPFIncludes []string `yaml:"spfIncludes"`
DMARC *DMARC `yaml:"dmarc"`
MTASts *MTASts `yaml:"mtaSts"`
TLSRpt string `yaml:"tlsRpt"`
BIMI *BIMI `yaml:"bimi"`
}
Deliverability configures the SPF, DMARC, MTA-STS, TLS-RPT, and BIMI records mailctl publishes alongside whatever a mail provider asks for.
type Domain ¶
type Domain struct {
Name string `yaml:"name"`
ZoneName string `yaml:"zoneName"`
Mail Mail `yaml:"mail"`
Mailboxes []Mailbox `yaml:"mailboxes"`
Aliases []Alias `yaml:"aliases"`
CatchAll *CatchAll `yaml:"catchAll"`
Deliverability Deliverability `yaml:"deliverability"`
}
func (Domain) AllTargets ¶
AllTargets returns every address this domain forwards to, deduplicated. Cloudflare Email Routing requires each of them to be a verified destination.
type DomainSettings ¶
type MS365 ¶
type MS365 struct {
// License is a skuPartNumber such as BUSINESS_BASIC, not a skuId GUID.
// It is the domain-level default; a mailbox's own Mailbox.License
// overrides it for that mailbox only.
License string `yaml:"license"`
// UsageLocation is an ISO 3166-1 alpha-2 code. Graph requires it on a user
// before a licence can be assigned.
UsageLocation string `yaml:"usageLocation"`
// DKIMCnames are the two targets copied from the Defender portal, for
// selector1 and selector2 in that order. Graph cannot supply them.
DKIMCnames []string `yaml:"dkimCnames"`
}
MS365 holds the Microsoft 365 settings for a domain. Fields Graph cannot change are absent by design; see the ms365 design doc.
type Mail ¶
type Mail struct {
Providers []string
Settings DomainSettings
MS365 *MS365
}
Mail holds the provider selection and provider-level domain settings. provider accepts either a scalar name or a list of names.
func (*Mail) UnmarshalYAML ¶
UnmarshalYAML decodes the mail: mapping by hand rather than via node.Decode(&raw): that call starts a fresh decode that does not inherit the top-level decoder's KnownFields(true), so a typo'd key would load silently. Walking Content in pairs keeps strictness for mail.provider, mail.settings, and the two settings keys, which are the domain-level security settings.
type Mailbox ¶
type Mailbox struct {
Address string `yaml:"address"`
PasswordEnv string `yaml:"passwordEnv"`
EnablePasswordReset *bool `yaml:"enablePasswordReset"`
EnableSearchIndexing *bool `yaml:"enableSearchIndexing"`
RequireTwoFactorAuthentication *bool `yaml:"requireTwoFactorAuthentication"`
SendWelcomeEmail *bool `yaml:"sendWelcomeEmail"`
Recovery []Recovery `yaml:"recovery"`
// DisplayName and License are ms365 fields. Validation rejects them on a
// domain using any other provider. License, when set, overrides
// MS365.License's domain-level default for this mailbox only.
DisplayName string `yaml:"displayName"`
License string `yaml:"license"`
}
type PurelymailConfig ¶
type PurelymailConfig struct {
BaseURL string `yaml:"baseUrl"`
}