[Mailman-Users] Another passwordless unsubscribe script

Neil Cooler ncooler at nandomedia.com
Mon Apr 9 19:26:48 CEST 2001


I tested out bob's Auto-Unsubscribe script
(http://nleaudio.com/bnotes/mailman.htm). 
I wasnt really too happy with the fact that it asked for the entire site
password because when a user unsubscribes, an email gets sent to the
site admin confirming that the action was completed.  This email
contains the site password.  I could have set up a separate script for
each list but that is too much work.  The script I wrote calls the
remove_member's program.  

Bob's script did not get the email address in the proper way in my
opinion.  I believe I got around this by getting the return-to address.

The script below also contains simple logic to make sure that the email
address was actually removed, and not simply attempted to be removed.

I included the script below so feel free to use it however you like.

I am using a beta of the evolution PIM so please be aware that this may
not word-wrap correctly.

--neil



#!/bin/bash
###################################################################
# Script for passwordless Mailman list unsubscription via email   #
###################################################################
#Neil Cooler <ncooler at nandomedia.com>                             #
###################################################################
#Last revised: 04/09/01                                           #
###################################################################
# Call from your /etc/aliases file like:                          #
# <listname>-unsubscribe: /home/mailman/unsub <listname) <domain> #
###################################################################

#gets $1 and $2 from the commandline input and adds those values to the
listname and domain vars.
listname=$1
domain=$2

#reads the second line of the email
read a2 ;

#Strips the email address from the second line and puts it in the
variable 'addr'
addr="`echo $a2 | awk '{print $2}'`" ;   

#Attempts to remove the user.  IF it does not succeed, it sends a
message to the user
status=`/home/mailman/bin/remove_members newtest $addr`
if [ -n "$status" ] 
then 
echo "From: $listname-admin@$domain" > /tmp/$addr
echo "To: $addr" >> /tmp/$addr
echo "Subject: $listname Unsubscription Confirmation" >> /tmp/$addr
echo "" >> /tmp/$addr
echo "There was an error in your attempt to unsusbscribe from the
$listname mailinglist." >> /tmp/$addr
echo "It appears that the address you tried to unsubscribe from, $addr
is not subscribed." >> /tmp/$addr
echo "Please contact $listname@$domain if you have any questions." >>
/tmp/$addr
/usr/lib/sendmail -f $listname-admin@$domain $addr < /tmp/$addr
rm -f /tmp/addr

#If the request works, it lets the user know he is unsubscribed.
else
echo "From: $listname-admin@$domain" > /tmp/$addr
echo "To: $addr" >> /tmp/$addr
echo "Subject: $listname Unsubscription Confirmation" >> /tmp/$addr
echo "" >> /tmp/$addr
echo "This message was generated to confirm your unsubscription from" >>
/tmp/$addr
echo "$listname@$domain.  You should no longer recieve any messages
from" >> /tmp/$addr
echo "this list.  If you change your mind, simply visit the list's" >>
/tmp/$addr
echo "Webpage at http://$domain/mailman/listinfo/$listname and subscribe
again.  If you have" >> /tmp/$addr
echo "any further questions, please email the admin at
$listname-admin@$domain.  " >> /tmp/$addr
echo "Thank You," >> /tmp/$addr
echo "List Admin" >> /tmp/$addr

/usr/lib/sendmail -f $listname-admin@$domain $addr < /tmp/$addr
rm -f /tmp/$addr
fi





More information about the Mailman-Users mailing list