This shows you the differences between two versions of the page.
qmail_and_procmail_how_to [2010/04/13 23:37] k2patel |
qmail_and_procmail_how_to [2020/08/10 02:35] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Qmail and Procmail How To ====== | ||
- | ==== qmail wrapper to check each mail ==== | ||
- | |||
- | <code sh | /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 | ||
- | </code> | ||
- | |||
- | ==== Define procmail rules ==== | ||
- | |||
- | This will send all messages with "//^X-Spam-Status: Yes//" and send those messages to \\ | ||
- | spammer@test.com email's inbox. | ||
- | |||
- | <code sh | /usr/local/etc/procmail.rc> | ||
- | SHELL=/bin/sh | ||
- | #LOGFILE=/tmp/procmail.log | ||
- | #VERBOSE=yes | ||
- | |||
- | :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 | ||
- | </code> | ||
- | |||
- | ==== Now run script using .qmail / .qmail-default ==== | ||
- | |||
- | <code sh | .qmail-default> | ||
- | | /usr/local/bin/qproc-wrap.sh | ||
- | | /usr/local/vpopmail/bin/vdelivermail '' bounce-no-mailbox | ||
- | </code> |