procmail
[Top] [All Lists]

Re: filtering mailboxes using Cron

1997-05-01 11:25:00
At the end of the month, I would like to filter work-related mail out 
of my "received" and "sent" folders.  Can I do this using procmail
and if so, how?  If somone could take the time to give a line-by-line
explanation of the example given in the man pages that would help.

Using the example from the procmail man page, take this:

          #!/bin/sh
 
          ORGMAIL=/var/spool/mail/$LOGNAME

and change it to:

          #!/bin/sh
 
          ORGMAIL=${1:-/var/spool/mail/$LOGNAME}

This will allow you to specify the mail file to filter on the command line
(if you don't specify a mail file, it will default to
/var/spool/mail/$LOGNAME.  Please beware that on some systems, such as
Solaris, your system mailbox is NOT in /var/spool, so this may need to be
changed). 

Let's say you put this script in a file called 'refilter'.  First make
sure refilter is executable (chmod 700 refilter) and make sure that it's
somewhere in your PATH; then you'd use it like this: 

  refilter ~/Mail/received

To filter all the messages in your received filter.  If you want to do
this at the end of every month, then run it at the end of every month.
The easiest way to do this automatically is to create a cron job that runs
monthly -- this will only work if you have access to the cron facility on
your system.  Your crontab entry (read the man pages for crontab) would
look like this:

00 00 01 * * $HOME/bin/refilter $HOME/mail/received

This would run refilter on your 'received' mail folder at midnight on the
first of the month.

-- Lars

---
Lars Kellogg-Stedman * lars(_at_)bu(_dot_)edu * (617)353-8277
Office of Information Technology, Boston University

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