unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] examples/unsubscribe.milter: RFC 8058 (List-Unsubscribe=One-Click)
Date: Sat,  2 Apr 2022 01:56:59 +0000	[thread overview]
Message-ID: <20220402015659.1539912-1-e@80x24.org> (raw)

This allows unambiguous signaling to some MUAs and webmail clients
that th List-Unsubscribe header contains an instantaneous
unsubscribe option.
---
 Documentation/standards.perl | 4 ++++
 examples/unsubscribe.milter  | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Documentation/standards.perl b/Documentation/standards.perl
index 32003c91..69568ceb 100755
--- a/Documentation/standards.perl
+++ b/Documentation/standards.perl
@@ -62,6 +62,10 @@ my $rfcs = [
 	# 8621 => JSON Meta Application Protocol (JMAP) for Mail
 	# ...
 
+	# examples/unsubscribe.milter and PublicInbox::Unsubscribe
+	2369 => 'URLs as Meta-Syntax for Core Mail List Commands',
+	8058 => 'Signaling One-Click Functionality for List Email Headers',
+
 	# TODO: flesh this out
 
 ];
diff --git a/examples/unsubscribe.milter b/examples/unsubscribe.milter
index 04a39761..216b0ddd 100644
--- a/examples/unsubscribe.milter
+++ b/examples/unsubscribe.milter
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-# Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use Sendmail::PMilter qw(:all);
@@ -96,6 +96,7 @@ $cbs{eom} = sub {
 
 		my $unsub = $priv->{header}->{'list-unsubscribe'} || [];
 		my $n = 0;
+		my $added;
 		foreach my $u (@$unsub) {
 			# Milter indices are 1-based,
 			# not 0-based like Perl arrays
@@ -114,7 +115,11 @@ $cbs{eom} = sub {
 			$v .= ",\n <https://$domain/u/$u/$list>";
 
 			$ctx->chgheader($k, $index, $v);
+			$added = 1;
 		}
+		# RFC 8058
+		$added and $ctx->addheader('List-Unsubscribe-Post',
+					'List-Unsubscribe=One-Click');
 	};
 	warn $@ if $@;
 	SMFIS_CONTINUE;

                 reply	other threads:[~2022-04-02  1:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220402015659.1539912-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).