[Mailman-Users] Adding users via email - No confirmation wanted.

Tim Faircloth tpf at canes.gsw.edu
Wed Apr 21 17:02:45 CEST 2004

At 10:24 AM 4/21/2004, you wrote:
>It's possible to write a perl script to parse an email and run 
>add_members... then set up an account on the server that is allowed to run 
>the script under sudo with no password... then have his .forward file 
>contain the line "| sudo scriptname".  Honestly it sounds like a hackish 
>way of doing it, but it could work.

Here's a sample script that I've whipped up quickly.  It's probably full of 
bugs and it's untested, but here it is.  I've added the capability to add 
regular users and digest users, as well as the ability to remove users from 
a list.

Assuming the moderator wanted to add joeuser at domain.com as a digest, 
joebuddy at domain.com as a regular, and remove nachobuddy at domain.com, the 
body of the email would look like this:

digest joeuser at domain.com
regular joebuddy at domain.com
remove nachobuddy at domain.com

----- begin script -----


$addargs="-w n -a n";


until(<STDIN> =~ /^$/) {
         # Do nothing... this loop throws away headers

# Remove one more line... the blank line between
# mail headers and body
$nothing = <STDIN>;

# add_members requires that email addresses be put in a file:
# one for regular subscriptions, one for digest subscriptions:
open(REGULAR, ">$addregtemp") || die "can't create tempfile regulartemp\n";
open(DIGEST, ">$adddigtemp") || die "can't create tempfile digesttemp\n";

# remove_members allows putting email addresses on the command line,
# so we can put all those email addresses in an array

while(<STDIN>) {
         if($_ =~ /^digest /) {
                 s/^digest //;
                 print DIGEST $_;
         } elsif ($_ =~ /^regular /) {
                 s/^regular //;
                 print REGULAR $_;
         } elsif ($_ =~ /^remove /) {
                 s/^remove //;
         } else {
                 print STDERR "invalid command";

close DIGEST;
close REGULAR;

# run the scripts using the info provided
system "$addscript $addargs -r $addregtemp -d $adddigtemp $listname";
system "$remscript $remargs $listname @removals";

# remove temp files
unlink $adddigtemp;
unlink $addregtemp;
----- end script -----

Tim Faircloth, System Administrator
Office: (229) 931-5076	Beeper: (229) 928-1458

More information about the Mailman-Users mailing list