Simple ListServ
One weekend I was struggling with a Listserv installation. It just
didn't do what I wanted it to do, and even worse: somehow, I ended up
creating a mail loop that fed hundreds of mail messages into my
mailbox in a matter of seconds. I had to stop the mail daemon, clear
out all queued messages (hundreds!), clean my mailbox.. Messy. I got
sooo fed up, that...
That I decided to cook my own Very Simple Listserv. It's very
simple indeed, but - it does what it's supposed to do, and it's very
manageable, integrates with SpamAssassin, and it's spam-free (so far).
It works. If you're interested, read on.
This mailing list server is intended at small interest groups. It
probably won't do too well in high-thruput environments, where
thousands of subscribers continuously bombard their groups with mails.
But it's simple to set up. If you have an average Linux system, you
can be up and running within 5 minutes.
Ingredients
To cook the Simple ListServ, you will need:
- A Unix (Linux) system with sendmail or postfix;
- A Perl interpreter;
- Root access;
- My Perl script that performs the necessary
functions, named listhandler and downloaded
here.
Recipy
In this recipy we'll cook up a new list, appropriately called
"mylist", on a domain "mydomain.org". Just follow the example and
supply your own values where appropriate.
-
Setting up a list user: As root, do
adduser -m mylist
I'm assuming that the user's home is /home/mylist; if the
home directory is different on your system, adapt where
appropriate. Now switch user to the new user:
su - mylist
-
The mylist environment: As user user mylist,
create a directory spool using:
mkdir spool
chmod 777 spool
Also create a directory bin, and copy the
script listhandler into the directory.
mkdir bin
cp /where/ever/you/put/it/listhandler bin/
chmod +x bin/listhandler
Next, edit bin/listhandler and modify the configuration at
the top to your likings. The configuration items are:
-
$subscriptions: The file with subscriptions. In our
example let's take /home/mylist/subscriptions.
-
$debugfile: The file where debugging information is
written.
-
$maxdebugsize: The max file size
of $debugfile. listhandler will "rotate" the log
when its size exceeds this value.
-
$dropspam: Set to 1 if you want spam to be discarded.
This works by inspecting the mail header X-Spam-Status
in delivered mails. When the value
is yes, listhandler simply drops the mail.
-
$mail: Set to your "mail" program,
normally /usr/bin/mail.
-
$spool: The "spool" directory, in our
example: /home/mylist/spool.
-
$maxmsg: Maximum messages to handle at one time. I have
this at 100. When there are more "pending" messages,
then listhandler simply won't act. I have this as a
protection against mail loops, since I don't expect to be
distributing more than 100 messages to each subscriber per
run.
Almost done. Now, edit /home/mylist/subscriptions and add
subscribers to mylist@mydomain.org. The format of the list
is: one subscriber per line, in the format Firstname Lastname
<e-mail@domain>. Empty lines and #-comment is allowed
(but the #-sign must be at the first column). For example:
# /home/mylist/subscriptions:
# List of subscribers to mylist@mydomain.org
John Doe <john@somewhere.org>
Jane Doe <jane@somwhere.else.org>
-
The mylist e-mail account: Log in as root again.
Define an e-mail account mylist that delivers the mail
contents to the listhandler script by
modifying /etc/aliases:
echo 'mylist: "|/home/mylist/bin/listhandler accept"' >> /etc/aliases
newaliases
-
Testing incoming mail: Now, send a mail
to mylist@mydomain.org. When all goes well, you will see a
new file in /home/mylist/spool. The file contains a prepared
mailing command, and the text that will be mailed.
You must send the mail as one of the subscribers, in our
example as either john@somewhere.org or
as jane@somewhere.else.org. Mails from non-subscribers are
not accepted by listhandler
If all goes not well, then:
-
Check /var/log/mail or /var/log/messages for
errors that your SMTP program has reported;
-
Check /tmp/mylist.log, the debug-log of listhandler.
-
Distributing mail to all subscribers: Now, as
user mylist, run:
/home/mylist/bin/listhandler distribute
This will send queued messages to the subscribers.
-
Automating distribution: Now that you've verified it all,
add a "crontab" to user mylist. As user mylist, run:
crontab -e
The line to add should look something like:
*/3 * * * * /home/mylist/bin/listhandler distribute >/dev/null
This runs the distribution process each 3 minutes, every hour,
every day.
Bon Appetit
You're all set to use
mylist@mydomain.org now. The only thing
you'll need to do, is to add or delete subscribers by hand in the
file
/home/mylist/subscriptions.
Also please note that
listhandler doesn't do non-text
mail well. It's basically just for text-passing.