Documentation
¶
Overview ¶
Package unsubscribe unsubscribes a person from a mailing list with the one-click web link the list's mail carries (RFC 8058): a List-Unsubscribe header that names an https URL, and a List-Unsubscribe-Post header of "List-Unsubscribe=One-Click". It is the only package that calls an unsubscribe link. MailRules never sends email on the person's behalf, so a list that offers only a mailto: address cannot be unsubscribed from here.
The link comes from the email, so whoever sent it chose it. Client calls it only on the public internet (publicnet): a link that leads to the daemon's own machine or network is refused when it is dialed, on the address actually connected to. The fake for tests is in unsubscribe/unsubscribetest.
Index ¶
Constants ¶
const Timeout = 10 * time.Second
Timeout bounds one unsubscribe request, connection and answer included.
Variables ¶
var ErrNotOneClick = errors.New("not a one-click unsubscribe link")
ErrNotOneClick means the link is not an RFC 8058 one-click link MailRules calls: not https, not on port 443, or not a URL at all. Nothing was sent.
Functions ¶
func OneClick ¶
OneClick returns the https link of an RFC 8058 one-click unsubscribe that headers (canonical keys, as message.Summary.Headers has them) offer, or "" when they offer none: no List-Unsubscribe, one that names only mailto: or http: links, or no List-Unsubscribe-Post of "List-Unsubscribe=One-Click".
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the daemon's Unsubscriber: an HTTP client that connects only to public addresses, sends no cookies, follows no redirect and gives up after Timeout.
type RefusedError ¶
RefusedError is the answer of a site that did not take the unsubscribe: any status but 2xx, a redirect included (RFC 8058 has the site answer the POST itself).
func (*RefusedError) Error ¶
func (e *RefusedError) Error() string
type Unsubscriber ¶
type Unsubscriber interface {
// Unsubscribe POSTs "List-Unsubscribe=One-Click" to link and returns nil when the site
// answered 2xx. An error never contains the link, which often carries a token that
// names the person; at most its host.
Unsubscribe(ctx context.Context, link string) error
}
Unsubscriber calls a one-click unsubscribe link. The daemon's is Client; tests use unsubscribetest.Fake.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package unsubscribetest is an in-memory unsubscribe.Unsubscriber for tests of the packages that unsubscribe.
|
Package unsubscribetest is an in-memory unsubscribe.Unsubscriber for tests of the packages that unsubscribe. |