#!/usr/local/bin/perl # # make an ARC prepass over a message and add an arc clause to # Authentication-Results header use strict; use Getopt::Std; use Mail::DKIM::ARC::Verifier; # local A-R server name my $srvid = "example.com"; my ($arseen, $chain); my @msg = ; my $arc = new Mail::DKIM::ARC::Verifier(Strict => 1); for $_ (@msg) { last if m{$^} and not $arseen; # don't bother if no A-R $arseen = 1 if m{^Authentication-Results: *$srvid;}i; # remove local line terminators my $l = $_; chomp($l); # use SMTP line terminators $arc->PRINT("$l\015\012"); } if($arseen) { # don't do ARC evaluation if no A-R $arc->CLOSE; $chain = $arc->result; } for $_ (@msg) { if($chain and m{^Authentication-Results: *$srvid;(.*)}) { print "Authentication-Results: $srvid; arc=$chain;$1\n"; $chain = undef; # once is plenty } else { print $_; } }