Simple Forwarder is a small BASH script which receives a mail via stdin and
The script can be downloaded here: Simple Forwarder
The following instructions are for Postfix. Other MTAs might behave similarly.
Create a directory (e.g. /etc/bestlists). Put a file "senders" in there, containing one address per line. These are the allowed senders. Create a file "mylistname.recipients" for every mailing list mylistname, also containing one address per line. These are the subscribers of the mailing lists. Make sure group nogroup (or whatever group or user Postfix uses on your system) has read access to them.
Touch some logfile (e.g. /var/log/bestlists.log) and make sure nogroup (or whatever group or user Postfix uses on your system) has write access to it.
Copy the Simple Forwarder script somewhere (e.g. /usr/local/bin), open it with a text editor and change the configuration variables at the beginning of the file. You might also want to change the text of the rejection message sent to unauthorized senders.
Create /etc/postfix/virtual entries for every mailing list you use, e.g. (.invalid has been used rather than .org to prevent spam robots from abusing this page):
best.eu.invalid anything ita@best.eu.invalid ita_at_best.eu.invalid itc@best.eu.invalid itc_at_best.eu.invalid
Create /etc/aliases etries for every mailing list you use:
ita_at_best.eu.invalid: "|/usr/local/bin/simple_forwarder ita" itc_at_best.eu.invalid: "|/usr/local/bin/simple_forwarder --bounces-to devnull@best.eu.invalid itc"
Don't forget to postmap /etc/postfix/virtual
and
newalias
afterwards. We need to have every mailing
list in virtual and in aliases because we cannot
pipe a mail to a command in virtual.
If you use just a single domain, you don't neet to create the virtual file at all. Just create entries like the following in /etc/aliases to enable mylist1@yourdomain and mylist2@yourdomain:
mylist1: "|/usr/local/bin/simple_forwarder mylist1" mylist2: "|/usr/local/bin/simple_forwarder --bounces-to devnull@best.eu.invalid mylist2"
You're done. Try it. If it doesn't work, see the log file. If there is nothing in the log file, Postfix (or the script, that is) might not be allowed to write there.
This script was written to be used in situations where you have your mailing lists in some kind of database with some kind of proprietary management interface and need a backend which actually does the mailing list distribution work. A fancy mailing list software would include web interface, a database for storing the subscribers, e-mail based subscription and tons of other features you don't want. Simple Forwarder does just the basics and is easy to adapt by anyone who knows bash.
If you change anything, you can send me the changes and I will put them on this page if I like them. ;-)
You can use, modify and distribute this script freely. If you want to sell it, you need my permission. If you use it, I'd be happy about a short mail telling me what you use it for and how you like it.