RE: Purge mailboxes of old mail

"Wayne Heming" <[email protected]>
Newsgroups gmane.mail.qpopper
Message-ID <[email protected]>
I have looked for something in this space for a while and couldn't find one.

So I wrote one myself.

It requires perl, Mail::POP3Client and Date::Manip modules

It also require you to know all the usernames and passwords. (text file)

If I can work out how the mail file works (about 50% there now) I can modify
it to work on them rather than logging in and deleting. This will remove the
dependency on the passwords.

It is crude but it works

Wayne



#!/usr/local/bin/perl

use Mail::POP3Client;
use Date::Manip;

#user list file, format is user password on each line
$user_list = "/usr/mail/user_list";

#number of days old for deletion
$age = 60;

$today = ParseDate("today");

#open a log file to log stuff
open (OFILE, ">>$today") || die("Sorry");

#open the password list
open (IFILE, "$user_list") || die("Sorry");
@lines = <IFILE>;
close("$user_list");

foreach (@lines) {
  ($user,$password) = split(/ +/);
    $deletecount=0;
    $pop = new Mail::POP3Client(    USER     => $user,
                                    PASSWORD => $password,
                                    HOST     => "localhost" );
    if ($pop->State eq "TRANSACTION") {
      for ($i = 1; $i <= $pop->Count(); $i++) {
        foreach ( $pop->Head( $i ) ) {
          if (/^(Date):\s+/i) {
            ($a,$b,$c,$d,$e,$f,$g) = split(/ +/);
            $pdate = ParseDate($c." ".$d." ".$e." ".$f." ".$g);
            $delta = Delta_Format(DateCalc($pdate,$today,\$err),"1","%dt");
            if ($delta > $age) {
              $deletecount = $deletecount+1;
              $pop->Delete($i);
             }
          }
        }
      }
      print OFILE ("Deleted $deletecount from user $user\n");
    } else {
      print OFILE ("Auth Failed for $user with password $password\n");
    }
  $pop->Close();
}
close (OFILE);







-----Original Message-----
From: The Doctor [mailto:[email protected]] 
Sent: Saturday, 11 November 2006 1:16 PM
To: Subscribers of Qpopper
Subject: Purge mailboxes of old mail

Does anyone know of a toll that would purge
mboxes of old e-mail?

-- 
Member - Liberal International	
This is [email protected]	Ici [email protected]
God Queen and country! Beware Anti-Christ rising!
Lest we forget 11 Nov 2006
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.