Documentation
¶
Overview ¶
Package rules holds a workspace's traffic rules (Sending providers › Traffic rules, review 2026-10 M34): the canary defaults (GS-10), the complaint watch after a send (GS-6), the thresholds by bounce type (GS-11) and the mailbox provider response rules (GS-12). The sending engine applies them; this package reads, validates and stores them and serves the screen's API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultCanary = Canary{Enabled: true, NewDomain: true, NeverMailed: true, OverUsual: true, Percent: 5, Seeds: true, WatchMinutes: 20, Gates: CanaryGates{Bounce: 1.0, BlockBounce: 0.2, Deferral: 15, Complaint: 0.10, SeedSpam: 2}}
DefaultCanary is the canary of a workspace that set none.
var DefaultReplyRules = []ReplyRule{ {Mailbox: "yahoo", Contains: "TSS04", Count: 10, WindowMinutes: 10, Action: "pause", DurationMinutes: 120, Enabled: true}, {Mailbox: "yahoo", Contains: "TS04", Count: 10, WindowMinutes: 10, Action: "pause", DurationMinutes: 120, Enabled: true}, {Mailbox: "outlook", Contains: "S3150", Count: 1, WindowMinutes: 10, Action: "pause_route", Enabled: true}, {Mailbox: "gmail", Contains: "421-4.7.28", Count: 5, WindowMinutes: 10, Action: "slow", DurationMinutes: 30, Enabled: true}, }
DefaultReplyRules are the response rules every workspace starts with (review GS-12): the replies mailbox providers are known for, acting as the Traffic rules board does. Outlook's S3150 means the sending IP is on Microsoft's block list, so its first one pauses Outlook on that route until someone resumes; Yahoo's TSS04 (and the older TS04) defers mail for volume or complaints, so ten in ten minutes pause Yahoo for two hours; Gmail's 421-4.7.28 rate-limits the sender, so five in ten minutes slow Gmail to half rate for 30 minutes. A rule matches plain text, so TS04 is its own rule (TSS04 doesn't contain it). People change or delete them on Traffic rules like any other rule.
var DefaultWatch = Watch{Enabled: true, Hours: 72, Alert: true, Postmaster: true}
DefaultWatch is the watch of a workspace that set none.
var Mailboxes = []string{"gmail", "outlook", "yahoo", "icloud", "other"}
Mailboxes a rule can name.
var ReplyActions = []string{"slow", "pause", "pause_route", "alert"}
ReplyActions are the actions a rule can take.
Functions ¶
func AddDefaultReplyRules ¶
AddDefaultReplyRules gives a new workspace the default response rules, in the caller's transaction.
func KnownReplyKey ¶
KnownReplyKey names a reply mailbox providers are known for, so the screen and the incident can say what it means in the reader's language ("" for one it doesn't know). Yahoo's TS04 and TSS04 both defer mail for unexpected volume or complaints; Microsoft's 5.7.515 refuses a bulk sender's domain without SPF, DKIM and an aligned DMARC pass.
Types ¶
type Canary ¶
type Canary struct {
// Enabled runs a canary automatically when one of the reasons below
// applies; a person can still choose one in Review & send.
Enabled bool `json:"enabled"`
// NewDomain: the sending domain or IP is new (first 30 days of sending
// from it).
NewDomain bool `json:"newDomain"`
// NeverMailed: some recipients never got mail from this domain.
NeverMailed bool `json:"neverMailed"`
// OverUsual: the audience is over twice the usual size (the median of
// the campaign's last 8 sends, or the workspace's).
OverUsual bool `json:"overUsual"`
// Percent of the audience, the most engaged first.
Percent float64 `json:"percent" minimum:"1" maximum:"20"`
// Seeds adds the workspace's connected seed mailboxes.
Seeds bool `json:"seeds"`
// WatchMinutes is how long the canary is watched before the gates.
WatchMinutes int `json:"watchMinutes" enum:"10,20,30,60"`
Gates CanaryGates `json:"gates"`
}
Canary is when a send starts with a canary and how it is judged.
func ParseCanary ¶
ParseCanary reads stored canary settings over the defaults.
func (Canary) Normalized ¶
Normalized is the canary with its values in range.
type CanaryGates ¶
type CanaryGates struct {
Bounce float64 `json:"bounce" minimum:"0.1" maximum:"20"`
BlockBounce float64 `json:"blockBounce" minimum:"0.01" maximum:"20"`
Deferral float64 `json:"deferral" minimum:"1" maximum:"100"`
Complaint float64 `json:"complaint" minimum:"0.01" maximum:"5"`
SeedSpam int `json:"seedSpam" minimum:"0" maximum:"100"`
}
CanaryGates are what the canary must stay under, in percent (SeedSpam: a count of seed mailboxes).
type ReplyRule ¶
type ReplyRule struct {
ID uuid.UUID `json:"id"`
Mailbox string `json:"mailbox"`
Contains string `json:"contains"`
// Count replies within WindowMinutes; 1 acts on the first reply.
Count int `json:"count"`
WindowMinutes int `json:"windowMinutes"`
// Action: slow (to half rate), pause (the mailbox provider on every
// route), pause_route (on the route that got the replies, with an
// alert) or alert.
Action string `json:"action"`
// DurationMinutes is how long a slowdown or pause lasts; 0 until
// someone resumes.
DurationMinutes int `json:"durationMinutes"`
Enabled bool `json:"enabled"`
Note string `json:"note"`
LastMatchedAt *time.Time `json:"lastMatchedAt,omitempty"`
LastCampaignID *uuid.UUID `json:"lastCampaignId,omitempty"`
}
ReplyRule is a mailbox provider response rule (review GS-12): when a mailbox provider's replies contain a text Count times within WindowMinutes, the send acts on that mailbox provider for a while.
func ReplyRules ¶
ReplyRules are a workspace's response rules, in their order.
type Watch ¶
type Watch struct {
Enabled bool `json:"enabled"`
// Hours the watch lasts after the send ends.
Hours int `json:"hours" enum:"24,48,72,168"`
// Alert tells the people who can resume sends when a mailbox provider
// passes its complaint limit during the watch.
Alert bool `json:"alert"`
// Postmaster reads Gmail's daily spam rate from Postmaster Tools.
Postmaster bool `json:"postmaster"`
}
Watch is the complaint watch after a send: complaints keep arriving for days after delivery.
func ParseWatch ¶
ParseWatch reads stored watch settings over the defaults.
func (Watch) Normalized ¶
Normalized is the watch with its values in range.