Expiring old mail in Maildir/
Elliot Finley
efinleywork at efinley.com
Thu May 29 09:15:10 PDT 2003
Here's a short Perl script that I run every night to clear out old mail from
my MailDirs
---
#!/usr/bin/perl -w
use strict;
use File::Find;
main();
exit;
sub usage {
print "$0 <maildir root> <days to keep>\n";
exit;
}
sub main {
usage() if (@ARGV != 2);
my $dir = $ARGV[0];
my $days = $ARGV[1];
usage() if (not -d $dir);
my $seconds = time() - ($days * 24 * 60 * 60);
my $wanted = sub {
#
# if we are looking at a mail file
#
if (my ($ft) = $_ =~ m|^(\d+)\.\d+\.|) {
if ($ft < $seconds) {
print "$File::Find::name\n";
unlink($File::Find::name);
}
}
};
find($wanted, $dir);
}
---
the regex in this line:
if (my ($ft) = $_ =~ m|^(\d+)\.\d+\.|) {
has to match the file name of your mail files. I use mail files named like
so:
1049831444.88767.thunderbird.etv.net,S=2514
timestamp.procId.domainname,S=filesize
----- Original Message -----
From: "Jamie Heckford" <jamie at tridentmicrosystems.co.uk>
To: "ODHIAMBO Washington" <wash at wananchi.com>
Cc: <freebsd-isp at freebsd.org>
Sent: Wednesday, May 28, 2003 10:31 AM
Subject: Re: Expiring old mail in Maildir/
On Friday 23 May 2003 5:19 pm, ODHIAMBO Washington wrote:
> Hiya ISP Admins,
>
>
> Apart from using `find`, I am wondering if someone already owns the wheel
> that can expire mail older than N number of days from users Maildir.
> I used to use one by Phil Male of Information Systems Engineering Group
> which was well adapted for mbox-type mailboxes, but now I have changed to
> Maildir/
>
> Thanks in advance for any pointers.
>
We use a tool called archivemail (/usr/ports/mail/archivemail).
I wrote a script that loops through all usernames and logs in via IMAP and
deletes messages older than 30 days.
Cheers,
Jamie
_______________________________________________
freebsd-isp at freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-isp
To unsubscribe, send any mail to "freebsd-isp-unsubscribe at freebsd.org"
More information about the freebsd-isp
mailing list