Python 3 port of open source email guardian TMDA (Tagged Message Delivery Agent)

By | January 12, 2023

[If you don’t run your own mail server and aren’t interested in doing that, you can safely skip this blog posting.]

My primary anti-spam strategy for my personal email account is a Bayesian spam filter built on top of bogofilter. That works fine for me, but it requires regular maintenance to keep it trained properly, so it’s not a good fit for my wife, who is less obsessed with tech than I am. Therefore, many years ago we set up her inbox to work as follows:

  • Any time she gets an email message from someone she hasn’t corresponding with before, it gets forwarded to me instead of landing in her inbox.
  • Most of the spam messages sent to her get trapped at that point by my spam filter and neither she nor I ever has to see them.
  • I review the ones that get through, release the legitimate messages into her inbox, and delete or feed to the spam filter the other ones.

To set this up, I used an open-source package called TMDA, or Tagged Message Delivery Agent. It has more functionality that what I just described, though we’re not using most of it. Here’s how its author describes it in his README file:

The technical countermeasures used by TMDA to thwart spam include:

  • whitelists: accept mail from known, trusted senders.
  • blacklists: refuse mail from undesired senders.
  • challenge/response: allows unknown senders which aren’t on the whitelist or blacklist the chance to confirm that their message is legitimate (non-spam).
  • tagged addresses: special-purpose e-mail addresses such as time-dependent addresses, or addresses which only accept certain kinds of communication. These increase the transparency of TMDA for unknown senders by allowing them to safely circumvent the challenge/response system.

It really is a neat piece of software, at least for people who are willing and able to run their own mail servers so they can integrate it into them.

As I said, my wife has been using TMDA to reroute emails from unknown senders to me for many years, which was fine… until its maintainer stopped maintaining it and Python 2, on which it is based, reached its end of life and was removed from most Linux distributions. Yesterday, I decided to upgrade our family email server from CentOS Stream 8 to CentOS Stream 9 because I needed a feature that was only available in 9, and when the upgrade was finished, Python 2 was completely gone, and with it TMDA.

I contemplated my options and decided the least annoying way to restore spam protections to my wife’s inbox was to port TMDA to Python 3 myself. That took about eight hours. When it was all finished, it occurred to me that I should tell people about it, so I went to find the TMDA users mailing list which actually still exists, only to discover from looking in the list archives that someone else already did this a few years ago. D’oh!

Be that as it may, my Python 3 port of TMDA is working just fine for me, so I decided to share it with the world in case it might be useful to anyone else. You can find it on Github. In addition to the Python 3 port of the old code, which was time-consuming but relatively straightforward, there is also a new script I wrote, a simple CGI script for doing some basic TMDA administrative tasks through a web server instead of from the command line. It’s in contrib/simple-tmda.cgi if you want to take a look.


Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *