Bruno Wolff III wrote:
> 
> On Tue, Feb 15, 2000 at 08:02:24AM +0100,
>   Hans Sandsdalen <[EMAIL PROTECTED]> wrote:
> >
> > I just want to remove the "host!" part of the string. I could of
> > course use .qmail files, but this will be a lot of work. There
> > is not a fixed number of hosts nor users at each host.
> 
> You can use the catch .qmail file (~alias/.qmail-default) and condredirect
> to do what you want. You need one condredirect line for each address that
> might have their mail forwarded this way.
> 
> If you really want to do generic relaying of this sort, then you can get
> by using formail to resend the message. Make sure you check the host
> you are forwarding to against a list of valid hosts so you don't get abused
> by spammers.

Made it this way:

in .qmail-default
---------------------------------
| preline /usr/local/bin/chkmail
| (echo Sorry, no mailbox here by that name. \(#5.1.1\); exit 100)
---------------------------------

/usr/local/bin/chkmail:
---------------------------------
#! /bin/sh
#
# forward mail to user@domain if adress is host!user@domain
#

#
# NB! make sure everyone has writeaccess to $LOGFILE
#
LOGFILE=/var/log/chkmail
FORWARD=/var/qmail/bin/forward

stdin_to_stdout()
{
   while read i
   do
      echo $i
   done
}


NRECIPIENT=`echo $RECIPIENT | cut -f2 -d\!`

if [ "$NRECIPIENT" != "$RECIPIENT" ]; then
   echo `date`: $RECIPIENT -\> $NRECIPIENT, From: $SENDER  >> $LOGFILE
   stdin_to_stdout | $FORWARD $NRECIPIENT

   RC=$?

   if [ $RC -eq 0 ]; then
      # skip the rest of the .qmail-default file processing
      exit 99
   else
      exit $RC
   fi
fi

# continue .qmail-default file processing
exit 0

-- 
/hans

Reply via email to