* Dave <david.greenhall@praybourne.co.uk>:
> Hi Everyone,
>
>
> I have procmail set up to scan emails for spam / viruses etc.. and then
> forward mail on to another server. Last week i had to set up one
> particular account locally. Now, I am trying to add a procmail rule to
> deliver mail locally for that one account and i cant seem to get it
> working.
>
> This is how my system was before:
> Sendmail cf file:
>
> LOCAL_RULE_0
> R$* < @ $=w > $* $#procmail $@
> /etc/mail/procmailrc-systemwide/procmailrc $: $1<@$2.procmail.>$3
> R$* < @ $=w. > $* $#procmail $@
> /etc/mail/procmailrc-systemwide/procmailrc $: $1<@$2.procmail.>$3
> R$* < @$* .procmail. > $* $1<@$2.>$3 Already filtered, map to original
> address
>
> ### end of file ###
>
> And the procmailrc:
>
> ### start of file ###
> DROPPRIVS=yes
> LOGFILE = /var/log/procmail.log
>
> ### Spamassassin start
> :0fw: spamassassin.lock
> * < 256000
> | /usr/bin/spamc
>
> ### Check for executables and drop
> :0B
> * ^(Content-(Type|Disposition):.*|[ ]*(file)?)name=("[^"]*|[^
> ]*)\.(bat|cmd|com|exe|js|pif|scr)
> /dev/null
>
> ### Deliver spam to folder
> :0:
> * ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*
> ! spamtrap@praybourne.local
>
> ### Scan again, just in case: Deliver spam to folder
> :0:
> * ^X-Spam-Status: Yes
> ! spamtrap@praybourne.local
>
> ### Backup all incoming email
> BACKUP=/usr/_mailbackup
> TODAY=`date +%d-%m-%Y`
> :0c:
> | formail -b >> $BACKUP/$TODAY
>
> ### This rule forwards on all email
> :0 w
> ! -oi -f "$@"
>
> ### end of file ###
> All of this works perfectly, now when i try to add a basic rule to
> catch mail for a local account it doesnt work. This is what i have been
> adding at the top of the procmail file:
>
> # Rule for local account to collect email before hitting spam trap.
> :0:
> * ^TO: localuser@ourserver.com
> ! localuser
>
> Will be grateful if anyone can tell me where i am going wrong.
It may be stuck in a loop. A piece of mail comes in for localuser, then its
forwarded to localuser. Then that mail goes through the procmail process again
and gets forwarded to localuser again (and again and again). Check your logs
(/var/log/procmail.log) to see if this is what's happening.
The easiest solution will probably be modifying that last rule to something
like:
:0 w
* ! ^TO_localuser@ourserver\.com
! -oi -f "$@"
This way everything (but localuser) is forwarded on to another host.