I (mostly) concur with what Bill Cole says (maybe I'd quibble with the
"2nd clause" part).
Here's a shopworn blade which is in my list of things to rewrite in Python
one day:
http://athena.m3047.net/pub/perl/mail-processing/realmailer.pl.txt
You call it from e.g. procmail, or in other words it expects a mail
message on STDIN and writes it back out with changes on STDOUT. It makes a
bunch of DNS queries. It adds a bunch of headers; it's up to you to do
with them as you wish.
It does a crappy job with SPF, oh well.
There are lots of reasons not to run this, and mitigations for most of the
reasons. I would strongly recommend pointing it at a local caching
resolver which is also used by the MTA.
On the plus side, it runs on Perl 5.26.1.
--
Fred Morris