feedback

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package feedback reads what the mail world reports back: delivery status notifications (bounces), abuse feedback reports (spam complaints), DMARC aggregate and TLS reports, and relay webhooks. It only parses; the engine decides what a bounce or complaint changes.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoReport = errors.New("no report found")

ErrNoReport means the message carries no readable report.

Functions

This section is empty.

Types

type Complaint

type Complaint struct {
	Type       string // abuse, fraud, ...
	Recipient  string // the complaining address, when the reporter discloses it
	OriginalID string // Message-ID of the reported message
	ListUnsub  string // its List-Unsubscribe header, which carries lfr's token
}

Complaint is an abuse report (RFC 5965).

func ARF

func ARF(p *msg.Parsed) (Complaint, bool)

ARF extracts a feedback report.

type DMARCRow

type DMARCRow struct {
	IP          string `json:"ip"`
	Count       int    `json:"count"`
	DKIM        string `json:"dkim"`
	SPF         string `json:"spf"`
	Disposition string `json:"disposition"`
}

DMARCRow is one source in a DMARC aggregate report.

type Event

type Event struct {
	Kind   string `json:"kind"` // bounce, complaint, unsubscribe
	Email  string `json:"email"`
	Hard   bool   `json:"hard"`
	Note   string `json:"note,omitempty"`
	Source string `json:"source,omitempty"` // the envelope sender of the original message, when the relay reports it
}

Event is a bounce, complaint or unsubscribe reported by a relay webhook.

func SESEvents

func SESEvents(s *SNS) ([]Event, error)

SESEvents reads the SES notification inside a verified SNS message.

func Webhook

func Webhook(contentType string, body []byte) ([]Event, error)

Webhook reads an SMTP2GO or generic {"type","email"} notification, as JSON or form data. Amazon SES notifications arrive signed through SNS and are read with SNSVerifier and SESEvents instead.

type Recipient

type Recipient struct {
	Email      string `json:"email"`
	Action     string `json:"action"` // failed, delayed, delivered, relayed, expanded
	Status     string `json:"status"` // e.g. 5.1.1
	Diagnostic string `json:"diagnostic,omitempty"`
}

Recipient is one recipient's outcome in a bounce.

func DSN

func DSN(p *msg.Parsed) (recipients []Recipient, originalID string, ok bool)

DSN extracts recipients from a delivery status notification (RFC 3464), and the Message-ID of the original message when it is included.

func (Recipient) Hard

func (r Recipient) Hard() bool

Hard reports a permanent failure.

type Report

type Report struct {
	Kind   string          `json:"kind"` // dmarc, tlsrpt
	Org    string          `json:"org"`
	ID     string          `json:"report_id"`
	Domain string          `json:"domain"`
	Begin  time.Time       `json:"begin"`
	End    time.Time       `json:"end"`
	Pass   int             `json:"pass"`
	Fail   int             `json:"fail"`
	Rows   json.RawMessage `json:"rows"`
}

Report is a summarized aggregate report.

func DMARC

func DMARC(p *msg.Parsed) (Report, error)

DMARC reads an aggregate report from a message.

func TLSRPT

func TLSRPT(p *msg.Parsed) (Report, error)

TLSRPT reads an SMTP TLS report (RFC 8460) from a message.

type SNS

type SNS struct {
	Type         string
	TopicArn     string
	SubscribeURL string
	Message      string
}

SNS is an Amazon SNS message whose signature checked out.

type SNSVerifier

type SNSVerifier struct {
	Client *http.Client
	// contains filtered or unexported fields
}

SNSVerifier checks SNS message signatures against Amazon's signing certificates, as AWS documents for HTTPS subscribers.

func (*SNSVerifier) Verify

func (v *SNSVerifier) Verify(ctx context.Context, body []byte) (*SNS, error)

Verify parses body as an SNS message and checks its signature.

Jump to

Keyboard shortcuts

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