User Tools

Site Tools


qmail_and_procmail_how_to

This is an old revision of the document!


Qmail and Procmail How To

qmail wrapper to check each mail

| /usr/local/bin/qproc-wrap.sh
#!/bin/sh
 
# original modified, taken from http://openwall.info/wiki/internal/email/qmail-procmail
 
/var/qmail/bin/preline /usr/local/bin/procmail /usr/local/etc/procmail.rc && exit 0
 
# check if procmail returned EX_TEMPFAIL (75)
[ $? -eq 75 ] && exit 111
 
# do we want to discard the message?
[ $? -eq 99 ] && exit 99
 
# otherwise return a permanent error
exit 100

Define procmail rules

This will send all messages with “^X-Spam-Status: Yes” and send those messages to
spammer@test.com email's inbox.

| /usr/local/etc/procmail.rc
SHELL=/bin/sh
#LOGFILE=/tmp/procmail.log
#VERBOSE=yes
 
EXITCODE=99
:0h
*^X-Spam-Status: Yes
/usr/local/vpopmail/domains/test.com/spammer/Maildir/new
 
# deliver the message normally
EXITCODE=0
#
 
# this line needs to be here
# or else all mail will get double delivered to Maildir
# and to /var/mail/vpopmail, slowly filling /var
:0
/dev/null

Now run script using .qmail / .qmail-default

| .qmail-default
| /usr/local/bin/qproc-wrap.sh
| /usr/local/vpopmail/bin/vdelivermail '' bounce-no-mailbox
qmail_and_procmail_how_to.1271369525.txt.gz · Last modified: 2020/08/10 02:30 (external edit)