Bob's Unofficial Mailman Tricks & Tips
Mailman is a very useful online mailing list program. Here are some modifications that I've done that you may find useful. Note that all code here is for running Mailman 2.x under Redhat or Mandrake Linux:
Subscription Username and Reason (03/18/01)
On some lists, it helps to get the full name of the person subscribing, along with perhaps a reason for subscribing, or finding out where they heard about the list. This shell script is more of a hack, but works pretty well. It does its thing by intercepting the Form Submit from the listinfo page, and sending its results to the administrator. It then passes the form on to Mailman for normal handling. Here's what it takes:
1. Download this script (mminfo). wget http://nleaudio.com/bnotes/mminfo
2. Edit the first three lines to customize it for your list. (You will need multiple copies of this script for each list that you desire to use this feature.) The default is a sample for a list called "test" at host www.nleaudio.com:
# Modify these three lines for your specific list:
3. Move it into your httpd's /cgi-bin/ directory for your domain, and rename it to your list name.
4. chmod 755 it to make it executable.
5. Download my modified ProcCgi.C program. wget http://nleaudio.com/bnotes/proccgi.c
6. Compile the sucker: gcc -o /usr/bin/proccgi proccgi.c You can nuke the proccgi.c file if you wish, now that we have the object code residing in /usr/bin.
7. Edit the HTML in your listinfo.html page, which resides inside your lists/(listname) directory.
Example: pico -w /home/mailman/lists/test/listinfo.html
A. Find the "<MM-Subscribe-Form-Start>" tag. Replace it with "<FORM Method=POST ACTION="/cgi-bin/test">, with "test" being changed to the name of your script (and list).
B. Find the end of the subscription form:
<TD BGCOLOR="#dddddd">Reenter password to confirm:</TD>
Now insert the following immediately after that:
<tr><td BGCOLOR="#dddddd">Enter your name:</td>
<td><INPUT type="Text" name="uname" size="30"></td>
<tr><td BGCOLOR="#dddddd">How did you hear about us?</td>
<td><INPUT type="Text" name="reason" size="60"></td>
8. Test it out! Hopefully it will work. Obviously, there may be some site-specific things that need tweaking, like the location of your cgi-bin directory, URL references, etc. You may need to add .CGI to the script (and thus change the Form Post URL).
This is somewhat of a hack, because the administrator gets two emails for subscriptions: one from this script, then the normal one from Mailman. Also be aware that the script gets called prior to Mailman's test of the passwords, so the admin may get a few extra emails. Have fun!
Auto Unsubscription (04/03/01)
One "feature" of Mailman is that users must use a password to unsubscribe. Many people simply want a easy way to unsubscribe, and this password verification can be a real pain. Here's another shell script hack to accomplish this.
1. Download this file (unsub). wget http://nleaudio.com/bnotes/unsub
2. Edit the file, and put your Mailman site password (or list password, if you're only going to use it for one list) up at the top:
sp="xxxx" # *** Put your site password here ***
3. chmod 755 unsub
4. Mov this into your /home/mailman directory (or equivalent).
5. Edit your mailman mail aliases file. We need to add the remove address, and call our unsub script with two parameters: list name, and domain name. Example: for the list called "test" at host nleaudio.com, I have:
test-remove: "|/home/mailman/unsub test nleaudio.com"
If you're using Postfix with virtual hosting, you'll need to edit the /etc/postfix/virtual file as well, like you normally do for mailman lists. Example:
6. That's it! Now when someone sends any email (even blank) to firstname.lastname@example.org, they will be automatically unsubscribed without asking for confirmation.
7. This script sends a short little email to the user telling them they have unsubscribed. If you have any text in the "Text sent to people leaving the list" box of the Mailman administration page, they will receive a second email with that text.
8. If you are using Sendmail, you may need to do the following mods, as identified by Kevin McCann:
For every script that you want sendmail to be able to run, you have to
create a symbolic link in the /etc/smrsh directory:
prompt> cd /etc/smrsh
prompt> ln -s /home/mailman/unsub unsub
Removing Excessive Headers (04/17/01)
Mailman conforms to all the latest RFCs regarding information that is contained in the message headers. However, it can be rather annoying scrolling through a page and a half of headers, half of which are mailman-related. Here's how you can remove them:
1. Find the file called CookHeaders.py. This should be located in: /home/mailman/Mailman/Handlers, if you have installed Mailman in /home/mailman. Make a copy of this file, and call it something like CookHeaders.py.orig. Do this with:
cp CookHeaders.py CookHeaders.py.orig
In case your mods don't work, you have a backup! Note: you'll also see a .pyc file. This is the compiled version of the file; but don't worry - when Python goes to run it, it will see the newer timestamp on your edited file, and re-compile it automatically.
2. Edit CookHeaders.py with your favorite editor. Right around line 116 (in version 2.0 final, at least), you'll see where the headers are added. Simply delete each line. Be careful not to upset the formatting, as the indentation is important in the Python language. You can safely remove: List-Unsubscribe, List-Subscribe, List-Post, List-ID, List-Help.
Please note that in doing so, you are straying from the RFCs, and potentially making it harder for your users to get help, unsubscribe, etc. You've been warned!