]> Sergey Matveev's repositories - public-inbox.git/commitdiff
examples/unsubscribe.milter: RFC 8058 (List-Unsubscribe=One-Click)
authorEric Wong <e@80x24.org>
Sat, 2 Apr 2022 01:56:59 +0000 (01:56 +0000)
committerEric Wong <e@80x24.org>
Sat, 2 Apr 2022 04:39:27 +0000 (04:39 +0000)
This allows unambiguous signaling to some MUAs and webmail clients
that th List-Unsubscribe header contains an instantaneous
unsubscribe option.

Documentation/standards.perl
examples/unsubscribe.milter

index 32003c912dee68f9e5ac4315dc51e22eb67c8e75..69568ceb3ce9887abd6804eddea3936e4dd73a69 100755 (executable)
@@ -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
 
 ];
index 04a3976142da5dc29b805052b7ae105fb30767ea..216b0dddd0cf737e77dfb3780f48b48c5fc9d1cd 100644 (file)
@@ -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;