Expand description
Parse List-Unsubscribe (RFC 2369) and List-Unsubscribe-Post (RFC 8058)
email headers into a typed action enum.
See the README for the rationale and coverage matrix.
use list_unsubscribe::{parse_with_post, UnsubscribeMethod};
let header = "<mailto:u@example.com>, <https://example.com/unsub?u=abc>";
let post = Some("List-Unsubscribe=One-Click");
match parse_with_post(header, post) {
UnsubscribeMethod::OneClick { url } => {
// POST to `url` with body `List-Unsubscribe=One-Click`
let _ = url;
}
UnsubscribeMethod::Mailto { address, subject } => {
let _ = (address, subject);
}
UnsubscribeMethod::HttpLink { url } => {
let _ = url;
}
UnsubscribeMethod::None => {}
}Enums§
- Unsubscribe
Method - The unsubscribe action a message exposes via its headers.
Functions§
- parse
- Parse a raw
List-Unsubscribeheader value into anUnsubscribeMethod. - parse_
from_ message mail-parser - Parse
List-Unsubscribefrom amail_parser::Messagein one call. - parse_
with_ post - Parse
List-Unsubscribetogether with the optionalList-Unsubscribe-Postheader.