Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 May 2003 10:14:58 -0600
From:      "Elliot Finley" <efinleywork@efinley.com>
To:        <jamie@tridentmicrosystems.co.uk>, "ODHIAMBO Washington" <wash@wananchi.com>
Cc:        freebsd-isp@freebsd.org
Subject:   Re: Expiring old mail in Maildir/
Message-ID:  <016801c325fd$73b71dc0$b45ad70a@elliotdevelop>
References:  <20030523161900.GA12569@ns2.wananchi.com> <200305281731.54434.jamie@tridentmicrosystems.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
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@tridentmicrosystems.co.uk>
To: "ODHIAMBO Washington" <wash@wananchi.com>
Cc: <freebsd-isp@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@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-isp
To unsubscribe, send any mail to "freebsd-isp-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?016801c325fd$73b71dc0$b45ad70a>