I'd recommend starting with mhonarc [1] (as Max has already identified), which is relatively simple to use, and extend it if you need something it can't yet do. It's written in Perl.
[1] https://packages.debian.org/trixie/mhonarc -- Jonathan Dowland [email protected] https://jmtd.net

