Help us shape the future of Go! Take the 2026 Go Developer Survey

mailtrust

package
v1.150.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package mailtrust decides which messages of the platform's mailbox a tool may show (#2247). A message is shown only when its From address is on the connection's allowlist and, unless the operator turned it off, the receiving server recorded that the sender's domain authenticated it: an SPF or DKIM pass aligned with From, or DMARC. Anyone can send to the address and write any From header, so these are rules the platform enforces, not judgments left to a model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allowlist

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

Allowlist is the senders whose mail is visible: whole addresses ("ap@vendor.example") and domains ("@vendor.example"). A domain entry matches that domain only, not its subdomains; name a subdomain to admit it.

func NewAllowlist

func NewAllowlist(entries []string) Allowlist

NewAllowlist reads the connection's allow_senders entries. Entries are case-insensitive; blank entries are ignored.

func (Allowlist) Allows

func (a Allowlist) Allows(addr string) bool

Allows reports whether addr is on the list.

type Judgment

type Judgment struct {
	Verdict Verdict
	// From is the sender's address as the From header names it.
	From string
	// Auth is what the receiving server recorded, as "dmarc=pass",
	// "dkim=pass (example.com)" or "none".
	Auth string
}

Judgment is the policy's reading of one message.

type Policy

type Policy struct {
	Allow Allowlist
	// RequireAuth requires an aligned SPF, DKIM or DMARC pass.
	RequireAuth bool
	// AuthServID is the receiving server's authserv-id: only an
	// Authentication-Results header carrying it is read. A sender can add
	// an Authentication-Results header of their own; they cannot make it
	// carry the receiving server's id past a server that strips forged ones
	// (RFC 8601 section 5), which is what the id is for.
	AuthServID string
}

Policy decides which messages a connection shows.

func (Policy) Judge

func (p Policy) Judge(from string, authResults []string) Judgment

Judge reads one message's From and Authentication-Results headers. from is the raw From header; authResults are the Authentication-Results header values in the order they appear, topmost first.

type Verdict

type Verdict string

Verdict is why a message is or is not shown.

const (
	// Trusted: the sender is on the allowlist and, when required, the
	// receiving server authenticated their domain.
	Trusted Verdict = "trusted"
	// NotAllowed: the From address is not on the allowlist.
	NotAllowed Verdict = "sender_not_allowed"
	// NotAuthenticated: on the allowlist, but no aligned pass was recorded
	// by the receiving server, so the From address may be forged.
	NotAuthenticated Verdict = "sender_not_authenticated"
	// BadFrom: the From header is missing, does not parse, or names more
	// than one address.
	BadFrom Verdict = "from_unreadable"
)

The verdicts a message can get.

Jump to

Keyboard shortcuts

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