my package of the day: listadmin – moderate mailman mailing lists from the console

Are you involved in moderating Mailman mailing lists? Then maybe you know the pain: As you try to stop spammers flooding you list you hold messages from unknown senders back for review. Or you have a moderated mailing list that only allows postings explicitly published. However. In most cases you get mails from Mailman telling you that there are messages you have to moderate. The common way is to enter the web interface, enter your password, read the messages and discard/reject/allow them.

This workflow is easy but it can really get on your nerves as the web stuff is somehow time consuming. Therefore from time to time you get lazy on moderating…

Well, there is light at the end of the tunnel and one cannot repeat this hint often enough: The package „listadmin“ provides a powerful console tool for moderating mailman mailing lists. As Debian/Ubuntu user you just have to install it via „aptitude install listadmin“ on the console or via Synaptic. You just have to write an .ini file with the configuration (admin url, credentials). The files looks like this:

adminurl https://hostname.tld/mailman/admindb/{list}
default skip
log ~/.listadmin.log
password secret
[email protected][email protected]

So we just give an url with a placeholder named „{list}“. This way we can moderate multiple lists with fewer lines of configuration. Now let’s see how listadmin behaves when checking existing mailing lists (in this case our Berlin based Ubuntu mailing lists):


Nothing to do – no messages to moderate in this case. But hey – we just got an incoming request. Let’s rerun listadmin and check:


A spammer tried to hit our list. We now can decide wether to Approve, Reject or Discard the message. If it’s spam you want to discard as this just deletes the message. When you want to provide feedback to the user, you have to reject and are able to enter a reason. Of you course you also can examine the full body of the message or just skip it and keep for the next session. In our case „d“ was entered for deleting the spam and the request was submitted. If you are fast the session will not take more than 10 seconds – try this with the web interface!

So though it’s age and the ajax web 2.0 shiny wysiwyg plinkplonk alternatives Mailman provides you with nice wrappers for moderating larger amounts of mails within seconds. If you stick to a community you will probably sooner or later be asked to moderate a mailing list. Now you can say: „No problem. I have a command line tool for this“.

using postfix for secure tests with live data

During web development and quality assurance you sometimes want to test an application with live data (e.g. a web shop test instance with live customer sql data). As your application implements mail functionality you have to make sure that no mail on the test server is sent to a real user but you probably want to be able to send mails to developers and receive all other outgoing test mails in a catch-all account. An easy Postfix tweak for this is using a pcre regular expression virtual map.

So our goal is: All outgoing mails to a specific domain should be delivered normally (e.g. your company domain) while all other outgoing mails should be delivered to one specific catch-all mailbox.

Actually this task can be resolved by adding not more than three lines of configuration code in two files.

1. in /etc/postfix/ add

virtual_alias_maps = pcre:/etc/postfix/virtual.pcre

2. the new /etc/postfix/virtual.pcre should look like

/(.+)@yourowndomain\.tld$/ ${1}@yourowndomain.tld
/(.+)@(.+)/ catchoutgoing@yourowndomain.tld

After having restarted postfix you are already done.

Please note, a ${0} instead of ${1}@yourowndomain.tld did not work for me, so this a tiny workaround which does not look beautiful but really does it’s job.

p.s.: A really nice (but somehow old looking) tool for developing and testing regular expressions is „redet„, a „regular expression development and execution tool“ which knows nearly every important regex syntax depending on the tools you have installed. You’ll find redet in your Debian/Ubuntu repository.