procmail
[Top] [All Lists]

Sorting a POP mailbox...

1996-01-18 04:42:13

I use procmail to sort mail for different users coming from my domain provider.

Scenario:

I get this mail with POP. When POP process is finished my popmail file is 
located in /usr/spool/mail/.popmail.

I have configured the file /etc/procmailrc to sort the users (the default user 
is me and I receive everything not sorted):

--------------------/etc/procmailrc---------------
PATH=/bin:/usr/bin:/usr/local/bin
MAILDIR=/usr/spool/mail
USER=$LOGNAME    #maybe not necessary
ORGMAIL=/usr/spool/mail/.popmail
DEFAULT=/usr/spool/mail/me
LOGFILE=/usr/spool/mail/procmail.log
VERBOSE=yes
# no lockmail is needed...

:0
* ^To:(_dot_)*user1(_at_)domain(_dot_)com
user1

:0
* ^To:(_dot_)*user2(_at_)micmac(_dot_)com
user2

etc...
--------------end of /etc/procmailrc---------------

Then I have my procmail file in my home (each user can have his one too for 
sure but I essentially receive all mailing lists...):

-------------- ~/.procmailrc-----------------------
PATH=/bin:/usr/bin:/usr/local/bin
MAILDIR=$HOME/Mailboxes
USER=$LOGNAME
ORGMAIL=/usr/spool/mail/.popmail
DEFAULT=/usr/spool/mail/me
LOCKFILE=$HOME/.lockmail
LOGFILE=/usr/spool/mail/procmail.log
VERBOSE=yes


:0 c
backup

:0 ic
| cd backup && rm -f dummy `ls -t msg.* | sed -e 1,32d`

:0
* ^Subject: test
|appnmail Admin/Tests

etc...
-----------end of ~/.procmailrc---------------------

Well... How all this is working?
When my .popmail file is created I launch manually the standard script given 
with procmail:
---------------POP-procmail-------------------------
#!/bin/sh

ORGMAIL=/usr/spool/mail/.popmail

if cd $HOME &&
 test -s $ORGMAIL &&
 lockfile -r0 -l3600 .newmail.lock 2>/dev/null
then
  trap "rm -f .newmail.lock" 1 2 3 15
  umask 077
  lockfile -l3600 -ml
  cat $ORGMAIL >>.newmail &&
   cat /dev/null >$ORGMAIL
  lockfile -mu
  formail -s procmail <.newmail &&
   rm -f .newmail
  rm -f .newmail.lock
fi
exit 0
-------------end of POP-procmail---------------------

And it works _PERFECTLY_! (mail user file are created with the correct 
ownerships, my mail is sorted as I want... all in one pass...)

Except for the fact that I have not succeeded in automatizing the process!!!!

I tried an entry in /etc/crontab.local but for some reason it just doesn't 
work...
And I find it somewhat inelegant...

I tried to launch my POP-procmail when the PPP connection is finished (in the 
ppp-down script): it doesn't work!

What I would prefer is that the script would be launched when my pop client has 
done it's job but I don't know how to do it...

Any suggestions?


---
__________________________________________________
Michel Coste  <mailto:mic(_at_)micmac(_dot_)com>
MiCMAC - Online Publishing  <http://www.micmac.com>

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