Skip to main content

Crate list_unsubscribe

Crate list_unsubscribe 

Source
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§

UnsubscribeMethod
The unsubscribe action a message exposes via its headers.

Functions§

parse
Parse a raw List-Unsubscribe header value into an UnsubscribeMethod.
parse_from_messagemail-parser
Parse List-Unsubscribe from a mail_parser::Message in one call.
parse_with_post
Parse List-Unsubscribe together with the optional List-Unsubscribe-Post header.