[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: useing formail and procmail to resort email



On Wed, 28 Jun 2000, Chris Dowling wrote:

<snip>

->I've just set up a new set of procmail recipies, and want to have all my
->mail resorted according to these rules.
->
->I know I can simply do
->	formail -s procmail < mailbox
->
->but I have many mailboxes, and one of the things I want to keep intact is
->the order (ie: date) that everything arrived.
->
->one idea I had was to get all the mailboxes in one file, then somehow sort
->that file in order of date arival.


*** I'm afraid you're mixing up a few things. If you want to sort on date,
go to your mail agent and sort it, if you want specific filtering rules
like puting mail from toto taratata com in $HOME/mail/totos_mail then you
put a filtering rule in $HOME/.procmailrc and you use the script which
follows. It reads .procmailrc, and filters your mailbox. Make sure the
destinations exist and don't do it while reading the mail in the mailbox
you're filtering!

## START ##

#!/bin/bash

ORGMAIL=/var/spool/mail/$LOGNAME

if cd $HOME &&
	test -s $ORGMAIL &&
	lockfile -r 0 -l 1024 /tmp/.newmail.lock 2>/dev/null
then
	trap "rm -f /tmp/.newmail.lock" 1 2 3 13 15
	umask 077
	lockfile -l 1024 -ml
	cat $ORGMAIL >> /tmp/.newmail &&
	cat /dev/null > $ORGMAIL
	lockfile -mu
	formail -s procmail < /tmp/.newmail &&
	rm -f /tmp/.newmail
	rm -f /tmp/.newmail.lock
fi
exit 0

	## END ##

Cheers!
   _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/
  _/ Zoran GRBIC       _/  Linux user & advocate  _/
 _/ UNIX Sys Analyst  _/  Both Micro$oft's clean _/
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/
Mailed with Linux & Pine...



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]