unsubscribe

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 13 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 unsubscribe works out how a list message can be left and sends RFC 8058 one-click requests (ADR-0027): an HTTPS POST that carries nothing of the user's and never reaches the user's own network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	Methods []Method // best first; none when the message offers nothing
	URL     string   // the https: URI, for OneClick and Web
	Host    string   // URL's host
	Address string   // the mailto: address
	Subject string   // the mailto: URI's subject; "unsubscribe" when it has none
	Body    string   // the mailto: URI's body
}

Info is what a message's headers offer.

func Parse

func Parse(listUnsubscribe, post, authResults string) Info

Parse reads a message's List-Unsubscribe, List-Unsubscribe-Post and first Authentication-Results headers. One-click needs an https: URI, the One-Click POST header, and the receiving provider's dkim=pass.

type Method

type Method string

Method is a way to unsubscribe, best first: OneClick, Mail, Web.

const (
	OneClick Method = "oneclick" // an HTTPS POST (RFC 8058)
	Mail     Method = "mail"     // a message to the mailto: address
	Web      Method = "web"      // the https: page, in the user's browser
)

type Poster

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

Poster sends one-click requests.

func New

func New() *Poster

New is a Poster that refuses every address inside the user's network. The check is lodge kit's netguard (ADR-0017 there), shared with the other apps: it refuses loopback, private, link-local, multicast, unspecified, shared (RFC 6598), the IETF protocol block, benchmarking, the reserved block, the documentation ranges, NAT64, Teredo, 6to4 and site-local, and it runs on each address after DNS.

func (*Poster) Post

func (p *Poster) Post(ctx context.Context, rawURL string) error

Post sends the one-click request: a POST of List-Unsubscribe=One-Click, with a fixed User-Agent and nothing else of the user's. A 2xx status is success.

Jump to

Keyboard shortcuts

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