Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Expiring old mail in Maildir/

0 views
Skip to first unread message

ODHIAMBO Washington

unread,
May 23, 2003, 12:19:51 PM5/23/03
to

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.


-Wash

--
Odhiambo Washington <wa...@wananchi.com> "The box said 'Requires
Wananchi Online Ltd. www.wananchi.com Windows 95, NT, or better,'
Tel: +254 2 313985-9 +254 2 313922 so I installed FreeBSD."
GSM: +254 72 743223 +254 733 744121 This sig is McQ! :-)


Stult's Report:
Our problems are mostly behind us. What we have to do now is
fight the solutions.
_______________________________________________
freeb...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-isp
To unsubscribe, send any mail to "freebsd-isp...@freebsd.org"

Joe Miller

unread,
May 23, 2003, 12:28:14 PM5/23/03
to
http://archivemail.sourceforge.net/

Usage: archivemail [options] mailbox [mailbox...]
Moves old mail in IMAP, mbox, MH or maildir-format mailboxes to an
mbox-format
mailbox compressed with gzip.

Options are as follows:
-a, --days-new=NUM archive messages _newer_ than NUM days
(default: 30)
-A, --date-new=DATE archive messages _newer_ than DATE
-d, --days=NUM archive messages older than NUM days
(default: 180)
-D, --date=DATE archive messages older than DATE
-o, --output-dir=DIR directory to store archives (default: same as
original)
-s, --suffix=NAME suffix for archive filename (default: '_archive')
-S, --size=NUM only archive messages NUM bytes or larger
-n, --dry-run don't write to anything - just show what would be
done
-u, --preserve-unread never archive unread messages
--delete delete rather than archive old mail (use with
caution!)
--include-flagged messages flagged important can also be archived
--no-compress do not compress archives with gzip
--warn-duplicate warn about duplicate Message-IDs in the same
mailbox
-v, --verbose report lots of extra debugging information
-q, --quiet quiet mode - print no statistics (suitable for
crontab)
-V, --version display version information
-h, --help display this message

Example: archivemail linux-kernel
This will move all messages older than 180 days to a 'mbox' mailbox
called
'linux-kernel_archive.gz', deleting them from the original
'linux-kernel'
mailbox. If the 'linux-kernel_archive.gz' mailbox already exists, the
newly archived messages are appended.

To archive IMAP mailboxes, format your mailbox argument like this:
imap://username:password@server/mailbox


--
Joe Miller


On Fri, May 23, 2003 at 07:19:00PM +0300, 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.
//
//
// -Wash
//
// --
// Odhiambo Washington <wa...@wananchi.com> "The box said 'Requires
// Wananchi Online Ltd. www.wananchi.com Windows 95, NT, or better,'
// Tel: +254 2 313985-9 +254 2 313922 so I installed FreeBSD."
// GSM: +254 72 743223 +254 733 744121 This sig is McQ! :-)
//
//
// Stult's Report:
// Our problems are mostly behind us. What we have to do now is
// fight the solutions.
// _______________________________________________
// freeb...@freebsd.org mailing list
// http://lists.freebsd.org/mailman/listinfo/freebsd-isp
// To unsubscribe, send any mail to "freebsd-isp...@freebsd.org"

ODHIAMBO Washington

unread,
May 23, 2003, 12:38:42 PM5/23/03
to
* Joe Miller <jo...@joeym.net> [20030523 19:26]: wrote:
> http://archivemail.sourceforge.net/
>
> Usage: archivemail [options] mailbox [mailbox...]
> Moves old mail in IMAP, mbox, MH or maildir-format mailboxes to an
> mbox-format mailbox compressed with gzip.

I would like to DELETE the messages and if possible, notify the owner
the same way "expire_mail" did.

If there are no other alternatives then I will seriously look at this
one, but I really need to "put a check on space usage". Archiving them
still uses space.

I know you will suggest I can delete the archive after creating it ;-)


Thanks

-Wash

--

Odhiambo Washington <wa...@wananchi.com> "The box said 'Requires

Wananchi Online Ltd. www.wananchi.com Windows 95, NT, or better,'

Tel: +254 2 313985-9 +254 2 313922 so I installed FreeBSD."

GSM: +254 72 743223 +254 733 744121 This sig is McQ! :-)


Uncle Ed's Rule of Thumb:
Never use your thumb for a rule. You'll either hit it with a
hammer or get a splinter in it.

Joe Miller

unread,
May 23, 2003, 12:46:02 PM5/23/03
to
You didn't read the full usage summary for archivemail:

--delete delete rather than archive old mail (use with
caution!)

--
Joe Miller


On Fri, May 23, 2003 at 07:37:55PM +0300, ODHIAMBO Washington wrote:
// * Joe Miller <jo...@joeym.net> [20030523 19:26]: wrote:
// > http://archivemail.sourceforge.net/
// >
// > Usage: archivemail [options] mailbox [mailbox...]
// > Moves old mail in IMAP, mbox, MH or maildir-format mailboxes to an
// > mbox-format mailbox compressed with gzip.
//
// I would like to DELETE the messages and if possible, notify the owner
// the same way "expire_mail" did.
//
// If there are no other alternatives then I will seriously look at this
// one, but I really need to "put a check on space usage". Archiving them
// still uses space.
//
// I know you will suggest I can delete the archive after creating it ;-)
//
//
// Thanks


//
// -Wash
//
// --

// Odhiambo Washington <wa...@wananchi.com> "The box said 'Requires
// Wananchi Online Ltd. www.wananchi.com Windows 95, NT, or better,'
// Tel: +254 2 313985-9 +254 2 313922 so I installed FreeBSD."
// GSM: +254 72 743223 +254 733 744121 This sig is McQ! :-)
//
//
// Uncle Ed's Rule of Thumb:
// Never use your thumb for a rule. You'll either hit it with a
// hammer or get a splinter in it.


// _______________________________________________
// freeb...@freebsd.org mailing list
// http://lists.freebsd.org/mailman/listinfo/freebsd-isp

// To unsubscribe, send any mail to "freebsd-isp...@freebsd.org"

zi...@one2net.co.ug

unread,
May 23, 2003, 12:48:24 PM5/23/03
to

if you are worried about space wouldnt something like setquota help ???
so that the user knows how much space they can actually use up, also makes
life easier for you the administrator.

cheers

David


> * Joe Miller <jo...@joeym.net> [20030523 19:26]: wrote:

>> http://archivemail.sourceforge.net/


>>
>> Usage: archivemail [options] mailbox [mailbox...]

>> Moves old mail in IMAP, mbox, MH or maildir-format mailboxes to an

>> mbox-format mailbox compressed with gzip.
>

> I would like to DELETE the messages and if possible, notify the owner

> the same way "expire_mail" did.
>

> If there are no other alternatives then I will seriously look at this

> one, but I really need to "put a check on space usage". Archiving them

> still uses space.


>
> I know you will suggest I can delete the archive after creating it ;-)
>
>

> Thanks
>
> -Wash
>
> --


> Odhiambo Washington <wa...@wananchi.com> "The box said 'Requires

> Wananchi Online Ltd. www.wananchi.com Windows 95, NT, or better,'

> Tel: +254 2 313985-9 +254 2 313922 so I installed FreeBSD."

> GSM: +254 72 743223 +254 733 744121 This sig is McQ! :-)
>
>

> Uncle Ed's Rule of Thumb:

> Never use your thumb for a rule. You'll either hit it with a

> hammer or get a splinter in it.

ODHIAMBO Washington

unread,
May 24, 2003, 3:14:54 AM5/24/03
to
* zi...@one2net.co.ug <zi...@one2net.co.ug> [20030523 19:47]: wrote:
>
> if you are worried about space wouldnt something like setquota help ???
> so that the user knows how much space they can actually use up, also makes
> life easier for you the administrator.
>
> cheers
>
> David

These users don't have shell accounts, and I do not want to use system
quotas. I use MTA-implemented quota.


-Wash

--
Odhiambo Washington <wa...@wananchi.com> "The box said 'Requires
Wananchi Online Ltd. www.wananchi.com Windows 95, NT, or better,'
Tel: +254 2 313985-9 +254 2 313922 so I installed FreeBSD."
GSM: +254 72 743223 +254 733 744121 This sig is McQ! :-)


One monk said to the other, "The fish has flopped out of the net! How
will it live?" The other said, "When you have gotten out of the net,
I'll tell you."

Chuck Swiger

unread,
May 24, 2003, 12:13:26 PM5/24/03
to
ODHIAMBO Washington wrote:
> * zi...@one2net.co.ug <zi...@one2net.co.ug> [20030523 19:47]: wrote:
>>if you are worried about space wouldnt something like setquota help ???
>>so that the user knows how much space they can actually use up, also makes
>>life easier for you the administrator.
>
> These users don't have shell accounts, and I do not want to use system
> quotas. I use MTA-implemented quota.

MTA's generally don't implement user quotas. In fact, a MTA like
sendmail doesn't even perform local delivery: the LDA, such as procmail
or mail.local does. Procmail or mail.local doesn't implement quotas
either: they depend on the system to provide that functionality.

-Chuck

Nielsen

unread,
May 24, 2003, 5:17:08 PM5/24/03
to
postfix can provide user quotas. Not everyone is using LDA's
antiquated enough to require a uid on the system for every account.

Cheers

Nate

ODHIAMBO Washington

unread,
May 26, 2003, 2:56:50 AM5/26/03
to
* Chuck Swiger <csw...@mac.com> [20030524 19:13]: wrote:
> ODHIAMBO Washington wrote:
> >* zi...@one2net.co.ug <zi...@one2net.co.ug> [20030523 19:47]: wrote:
> >>if you are worried about space wouldnt something like setquota help ???
> >>so that the user knows how much space they can actually use up, also makes
> >>life easier for you the administrator.
> >
> >These users don't have shell accounts, and I do not want to use system
> >quotas. I use MTA-implemented quota.
>
> MTA's generally don't implement user quotas. In fact, a MTA like
> sendmail doesn't even perform local delivery: the LDA, such as procmail
> or mail.local does. Procmail or mail.local doesn't implement quotas
> either: they depend on the system to provide that functionality.


I meant mail quota - on the Maildir/ There is nothing else these users
can put on the server. They do not have shell access, and also no ftp
access. And I do MTA-imposed quota on the Maildir/
Have you heard of Exim (www.exim.org) ? It does impose quotas on the
Maildir. I do it here ;-)

-Wash

--
Odhiambo Washington <wa...@wananchi.com> "The box said 'Requires
Wananchi Online Ltd. www.wananchi.com Windows 95, NT, or better,'
Tel: +254 2 313985-9 +254 2 313922 so I installed FreeBSD."
GSM: +254 72 743223 +254 733 744121 This sig is McQ! :-)


Oliver's Law:
Experience is something you don't get until just after you need
it.

zi...@one2net.co.ug

unread,
May 26, 2003, 3:31:45 AM5/26/03
to

Yes i have heard of exim i use it on 2 Of my major mail servers :), also
have some postfix running on another.

cheers

ziggy

Chuck Swiger

unread,
May 26, 2003, 4:31:11 PM5/26/03
to
ODHIAMBO Washington wrote:
[ ... ]

> I meant mail quota - on the Maildir/ There is nothing else these users
> can put on the server. They do not have shell access, and also no ftp
> access. And I do MTA-imposed quota on the Maildir/
> Have you heard of Exim (www.exim.org) ? It does impose quotas on the
> Maildir. I do it here ;-)

I've heard of Exim, although I have not used it. I am more familiar
with mail systems like Cyrus, as well as it's predecessor, the Andrew
Message System, and Courier. I remember MMDF, which CMU was using way
back when, and I'd even worked on a SMTP-to-X.400 gateway product back
in the early 90's.

For choice, I'd spend my time on this list helping people rather than
debating terminology, but that's only a preference. If you want to say
that Exim has "MTA-imposed quota", fine. (*)

In the future, please try to mention important details instead of
expecting people to guess that you weren't using FreeBSD's default MTA.

--
-Chuck

(*): I find the distinction between the various components of a mail
system-- the "MTA", "LDA", "MUA", and related software like a "POP3" or
"IMAP" server-- to be well-defined and meaningful. Exim handles
per-user quotas for mailboxes. However, the part of Exim which does
SMTP-- the MTA-- doesn't perform local delivery, does it?

Troy Settle

unread,
May 27, 2003, 7:21:34 AM5/27/03
to

> -----Original Message-----
> From: owner-fr...@freebsd.org
> [mailto:owner-fr...@freebsd.org] On Behalf Of Chuck Swiger
> Sent: Monday, May 26, 2003 4:31 PM

>
> (*): I find the distinction between the various components of a mail
> system-- the "MTA", "LDA", "MUA", and related software like a
> "POP3" or
> "IMAP" server-- to be well-defined and meaningful. Exim handles
> per-user quotas for mailboxes. However, the part of Exim which does
> SMTP-- the MTA-- doesn't perform local delivery, does it?
>

Local delivery, remote delivery, who cares? Mail is being transferred.
If you want to use sendmail as a point of reference, then yes, sendmail
does handle local delivery. It does so with exactly one delivery
mechinism: the pipe.

I would argue that the MTA (mail transfer agent) has nothing at all to
do with SMTP (simple mail transfer protocol), which is simply a
mechanism for clients to talk to servers and for servers to talk to
other servers.

What if I run sendmail in such a way that it's not listening for network
connections? Is it still an MTA?

--
Troy Settle
Pulaski Networks
http://www.psknet.com
540.994.4254 ~ 866.477.5638
Pulaski Chamber 2002 Small Business Of The Year

Randy Smith

unread,
May 27, 2003, 10:56:22 AM5/27/03
to
On Fri, 23 May 2003, ODHIAMBO Washington wrote:

> Date: Fri, 23 May 2003 19:19:00 +0300
> From: ODHIAMBO Washington <wa...@wananchi.com>
> To: "freeb...@freebsd.org" <freeb...@freebsd.org>
> Subject: Expiring old mail in Maildir/
>
>
> 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.
>
>

> -Wash
>
>

I wrote a script to clean out users' Spam folders. You can find it here:
http://perlstalker.amigo.net/courier/scripts/clean-spam.txt

You will need to modify it a little bit so that it looks in the right
place, but it's a simple enough script.

--
Randy Smith
Amigo.Net Systems Administrator
1-719-589-6100 x 4185
http://www.amigo.net/

Jamie Heckford

unread,
May 28, 2003, 12:32:01 PM5/28/03
to
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 whe=

el
> 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 an=
d=20
deletes messages older than 30 days.

Cheers,

Jamie

John Shafto

unread,
May 28, 2003, 7:43:21 PM5/28/03
to
Here are some sexy scripts:

#!/bin/tcsh -f
# Get the current epoch number, subtract a year,
# and remove all mail files older.

touch /root/curtime
set epno=`filetest -M /root/curtime`
set days=365
set expiresecs=`expr $days \* 86400`
set expiretime=`expr $epno - $expiresecs`
#set yearago=`expr $epno - 31536000`
#set weekago=`expr $epno - 604800`

set imapdirs='cur new'

cd /home
foreach U (`ls`)
cd $U/Maildir foreach M ($imapdirs)
echo -n "Checking: " ; pwd
foreach M ($imapdirs)
if (-e "$M") then
cd $M
foreach F (`ls`)
if (-M "$F" <= $expiretime) then
echo " Deleting: $M/$F"
rm "$F"
endif
end
cd ..
endif
end
cd /home
end

// --> Here's one to kill spam:

#!/bin/tcsh -f
# Get the current epoch number, subtract $expiretime,
# and remove all mail files older.

touch /root/curtime
set epno=`filetest -M /root/curtime`

set days=7
set expiresecs=`expr $days \* 86400`
set expiretime=`expr $epno - $expiresecs`
set imapdirs='cur new'
set count=0

cd /home
foreach U (`ls`)
if (-e "$U/Maildir/.Spam") then
cd $U/Maildir/.Spam
else
continue
endif
echo -n "Checking: " ; pwd
set count=`expr $count + 1`
foreach M ($imapdirs)
if (-e "$M") then
cd $M
foreach F (`ls`)
if (-M "$F" <= $expiretime) then
echo " Deleting: $M/$F"
rm "$F"
endif
end
cd ..
endif
end
cd /home
end
echo .
echo "Directories checked for old spam: $count"


--
Politicians say, "Mo' taxes will solve everything!"
(and the band played on)
'Round and around and around we go.
Where the world's headed, nobody knows.
(Great GoogaMooga can't ya hear me talkin' to ya?)
-- The Temptations


"ODHIAMBO Washington" <wa...@wananchi.com> wrote in message
news:balhn7$139h$1...@FreeBSD.csie.NCTU.edu.tw...

Elliot Finley

unread,
May 29, 2003, 12:15:32 PM5/29/03
to
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" <ja...@tridentmicrosystems.co.uk>
To: "ODHIAMBO Washington" <wa...@wananchi.com>
Cc: <freeb...@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

0 new messages