procmail
[Top] [All Lists]

Re: "re-delivering" doesn't function

1996-01-07 14:40:25
Alexandre Molari (molari(_at_)iprolink(_dot_)ch) wrote:
hello,
I'm using linux and I'm connected to Internet with an Internet access 
provider.
I have a POP mailbox.
my mail does this travel:
1. I retreive my mail from the POP box and give it to a special user
2. This user has a .forward and a .procmailrc file and give the mail to
  the different users SPOOL MAIL directories
3. Each user has his own .forward and .procmailrc and then distributes the 
mail
   from its SPOOL MAIL dir to the different folders.

The problem is that it functions till point 2. 

How are you retrieving your mail? Are you using popclient? Popclient 
simply places incoming mail in your mailbox, without doing anything more.
It will simply ignore your .forward, for instance.

Also, popclient in really *nasty* because it doesn't lock anything.

My solution is shown below, and I think it is pretty safe.
You'll still meed the .procmailrc, of course.
You start the script "pop" as your "special" user.

For debugging, error messages etc. appear in pop.log, and old
mails is retained in .popmail.o*

I'm not sure what your criteria for further delivery is, but I
assume you want to specify it in your .procmailrc

Enjoy!

Egil

---file:pop -------------------------------------------------------
#!/bin/sh
#
#NOTE: update these:
#
USERNAME=egilk
PASSWORD=secret
CONTINUE=$HOME/bin/pop.continue

#
# get access to local file..
if cd $HOME; then
   if /usr/local/bin/lockfile -r0 -l3600 .popmail.lock 2>>pop.log; then
       trap "rm -f .popmail.lock" 1 2 3 15
    else
       echo `date`: pop cannot lock >> pop.log
       exit 1
    fi
else 
   echo `date`: cd $HOME >> $HOME/pop.log
   exit 1
fi

#
# then download new contents...
# for debugging, add -k to keep the mail
#
echo `date`: pop begin >> pop.log

#BUG: password shows...
popclient -3 -v mail.oslonett.no -u $USERNAME -p $PASSWORD \
          -o .popmail 2>> pop.log

#
# now run procmail to process this,   
# spawned so that we don't tie up the dialup connection
#
echo `date`: processing mail >> pop.log

$CONTINUE &

exit 0
-------------------------------------------------------------------
---file:pop.continue ----------------------------------------------
#!/bin/sh
#
# called by "pop"
# continue POP handling
# IMPORTANT NOTE: assume file .popmail exists, and is locked
#

umask 077
cd $HOME

if [ -s .popmail ]; then
    if ![ -e .popmail.o ]; then
        echo -n > .popmail.o
    fi

    echo `date`: run procmail >> pop.log

    /usr/local/bin/formail -s /usr/local/bin/procmail -t <.popmail &&
    mv .popmail.o .popmail.oo &&
    mv .popmail .popmail.o &&
    echo -n > .popmail
fi

rm -f .popmail.lock
exit 0
-------------------------------------------------------------------

--
Email: egilk(_at_)sn(_dot_)no  Voice: +47 2252 3641, 920 22780 Fax: +47 2252 
5899
Snail: Egil Kvaleberg, Husebybakken 14A, 0379 Oslo, Norway
URL:   http://www.sn.no/~egilk/    

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