provider

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package provider recognises which large mailbox provider (Gmail, Microsoft, Yahoo) produced a deferral or bounce, and maps the provider's own codes to a recovery playbook: ordered next steps plus the provider's official pages.

It only reads reply texts. It never contacts a provider, files a request or changes anything.

Index

Constants

View Source
const (
	Gmail     = "gmail"
	Microsoft = "microsoft"
	Yahoo     = "yahoo"
)

Provider ids.

View Source
const (
	KindDeferral = "deferral"
	KindBounce   = "bounce"
	KindQueued   = "queued"
)

Kinds of evidence for Collector.Add.

Variables

View Source
var Providers = []Info{
	{Gmail, "Gmail / Google Workspace", []string{"google.com", "googlemail.com"}},
	{Microsoft, "Microsoft (Outlook.com / Microsoft 365)", []string{"protection.outlook.com", "outlook.com", "hotmail.com", "office365.com"}},
	{Yahoo, "Yahoo / AOL", []string{"yahoodns.net", "yahoo.com", "aol.com"}},
}

Providers lists every provider postsleuth knows, in display order.

Functions

func Detect

func Detect(text, rcptDomain string) string

Detect names the provider behind a failure text: first from the remote host Postfix talked to ("host gmail-smtp-in.l.google.com[...] said:"), then from provider-specific markers in the reply (gsmtp, S3150, [TSS04], ...), then from the recipient domain. It returns "" when nothing matches.

func Name

func Name(id string) string

Name returns the display name of a provider id ("" if unknown).

func Short

func Short(id string) string

Short returns a compact display name: Gmail, Microsoft, Yahoo.

Types

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

Collector merges failures from the queue and the log into playbook hits.

func NewCollector

func NewCollector() *Collector

NewCollector returns an empty collector.

func (*Collector) Add

func (c *Collector) Add(kind, text string, domains []string, n int) Match

Add records n failures of the given kind with this reply text.

func (*Collector) Result

func (c *Collector) Result() []Hit

Result returns hits, the most affected first.

type Hit

type Hit struct {
	Playbook  Playbook `json:"playbook"`
	Codes     []string `json:"codes_seen"`
	Notes     []string `json:"code_notes,omitempty"`
	Temporary bool     `json:"temporary"`
	Deferrals int      `json:"deferred_attempts"`
	Bounces   int      `json:"bounces"`
	Queued    int      `json:"queued_recipients"`
	Domains   []string `json:"domains"`
	Example   string   `json:"example"`
}

Hit is a playbook that applies to failures seen on this server, with the evidence: how often, for which domains, and one example reply.

type Info

type Info struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	// Hosts are MX / relay host suffixes the provider answers from.
	Hosts []string `json:"mx_hosts"`
}

Info describes a provider.

type Match

type Match struct {
	Provider string `json:"provider,omitempty"` // gmail, microsoft, yahoo; "" if not recognised
	// Playbook is nil when the provider was recognised but has no playbook
	// for this reply (e.g. a plain "user unknown").
	Playbook *Playbook `json:"-"`
	ID       string    `json:"playbook,omitempty"`
	Code     string    `json:"code,omitempty"`      // the provider code seen, e.g. 4.7.28, S3150, TSS04
	Note     string    `json:"code_note,omitempty"` // provider's explanation of Code, if published
	// Temporary is true when Postfix's own retries can succeed.
	Temporary bool `json:"temporary"`
	// contains filtered or unexported fields
}

Match is the result of looking up one reply text.

func Lookup

func Lookup(text, rcptDomain string) Match

Lookup detects the provider of a failure text and finds its playbook. rcptDomain is optional and only used when the text itself is ambiguous.

type Playbook

type Playbook struct {
	ID       string `json:"id"`
	Provider string `json:"provider"`
	// Codes is the family of reply codes this playbook covers, for display.
	Codes   string   `json:"codes"`
	Title   string   `json:"title"`
	Meaning string   `json:"meaning"`
	Steps   []string `json:"steps"`
	Refs    []Ref    `json:"references"`
	// CodeNotes holds the provider's own one-line explanation per code,
	// where the provider publishes one (e.g. Outlook.com SC-001..OU-002).
	CodeNotes map[string]string `json:"code_notes,omitempty"`
	// contains filtered or unexported fields
}

Playbook is an ordered recovery procedure for one provider failure.

func All

func All() []Playbook

All returns every built-in playbook, grouped by provider.

func Get

func Get(id string) (Playbook, bool)

Get returns the playbook with the given id.

type Ref

type Ref struct {
	Title string `json:"title"`
	URL   string `json:"url"`
}

Ref is an official reference page.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL