home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
linuxmafia.com 2016
/
linuxmafia.com.tar
/
linuxmafia.com
/
pub
/
linux
/
utilities-general
/
mailmandelete.script
< prev
next >
Wrap
Text File
|
2005-01-21
|
2KB
|
51 lines
#!/usr/bin/perl
# Created by Jimmy O'Regan
## This script was intended by its author to be called "admreqrm-2.pl",
## but for some reason Apache httpd refuses to offer the public access
## to any file of that name.
##
## Script to automate the deletion of spam from Mailman's admin queue,
## via screen-scraping and filling in of the required fields on the
## administrative Web forms. Requires a reasonable Perl installation
## and the WWW::Mechanize module from CPAN. WARNING: This script will
## delete ALL of a specified Mailman mailing list's current held mail,
## so you'll want to clear any exceptions manually before running it.
##
## Discussion that produced this script can be read here:
## http://linuxgazette.net/110/tag/8.html
use warnings;
use strict;
use WWW::Mechanize;
##### User-configurable variables #######################
my $password = 'PASSWORD';
my $url = 'URL';
# Set to non-zero to generate a troubleshooting log
my $debug = 0;
##### Past this point, There Be Dragons... ##############
my ( $mech, $content, %name ) = WWW::Mechanize -> new();
$mech -> get( $url );
$mech -> submit_form( fields => { adminpw => $password } );
$content = $mech -> content();
die "\u$&.\n" if $content =~ /no pending requests/;
for ( grep /^senderaction-/, split /[ \n"']/, $content ){
unless ( exists $name{ $_ } ){
print "Deleting $_\n";
$name{ $_ } = 3;
}
}
$mech -> submit_form( fields => \%name );
if ( $debug ){
use Data::Dumper;
open Fh, ">admreqrm.log" or die "Can't open log $!\n";
print Fh Dumper( %{ $mech->response() } );
}