From: "Carlos E. R."
Date: Mon, 10 Jul 2023 18:43:16 +0200
. . .
I'll have to try formail next to remove spam headers, then try with
Thunderbird, which is the best of the three, when it works.
--
Cheers / Saludos,
Carlos E. R.
(from 15.4 x86_64 at Telcontar)
If you still need a filter to remove headers from mbox files, you could
try this.
-- Bob Rogers
http://www.rgrjr.com/
#!/usr/bin/perl
#
# Filter to remove one or more headers from an mbox file.
#
# [created. -- rgr, 4-Jul-23.]
use strict;
use warnings;
die "$0: Need at least one header name (e.g 'sender') on the command line.\n"
unless @ARGV;
my $header_regexp = lc(join('|', @ARGV));
@ARGV = ();
die "$0: Header names must not have colons or spaces.\n"
if $header_regexp =~ /[ :]/;
warn "header_regexp '$header_regexp'";
my $in_headers = 0;
while (<>) {
if (/^From /) {
$in_headers = 1;
print;
}
elsif (/^$/) {
$in_headers = 0;
print;
}
elsif (! $in_headers) {
print;
}
elsif (/^($header_regexp):/i) {
$in_headers = 'skip';
}
else {
$in_headers = 1
# new header.
if /^\S/;
print
unless $in_headers eq 'skip';
}
}