procmail
[Top] [All Lists]

Re: limit mesages per box

1998-07-22 06:38:02
On Tue, Jul 21, 1998 at 08:15:37PM -0700, John D. Hardin wrote:
On Tue, 21 Jul 1998, Brad Wyman wrote:

is it posible to set procmail to do this:

1: sort mail 
2: count the # of mesages already in the box
3: if there are "X" mesages in the box, deleate the oldist
4: put new mail in box
[...]
Well, yes, but I think you'll have to give up the single-mailbox model and
go with the message-per-file model.

No, maybe not...  This is probably slower, but I think it would let
him keep his single-mailbox model.

To count the number of messages:

formail -s echo "message" < /var/mail/tim | wc -l

And to delete the oldest message,

formail +1 -s cat < /var/mail/tim > /var/mail/tim~
mv /var/mail/tim~

There's probably a faster way to delete the oldest message.  If you
have large mailboxes, using formail -s might be too slow, in which
case you'll need to think of something else.

And you'll need to be very careful to use appropriate lockfiles.

I'm not sure exactly what will happen if the above tries to delete a
message while you're using your favourite mail reader to read from the
same mailbox...


-- 
This .sig is not innovative, witty, or profund.

<Prev in Thread] Current Thread [Next in Thread>