Before I used qmail, I used fetchmail and old school procmail.
I had very well developed procmail filters and even after
switching to qmail I continued to use procmail for what
it was designed for, conditional mail filtering. Header
rewriting, forwarding, whatever, it is a powerful tool
with concise syntax. Here's an old .qmail file to invoke...
# .qmail
./Mail/pretmda/
|preline -f procmail
|exit 99
I kept a backup incase I borked the procmail config,
the pretmda maildir would be purged of files over a
week old with find.
my .procmailrc file is 1000 lines long but here are some
representative filter data
LOGFILE=$HOME/.procmail-logfile
SENDMAIL=/var/qmail/bin/sendmail
SENDMAILFLAGS="-oem -oi"
MAILDIR=$HOME/Mail
DEFAULT=$MAILDIR/stray/
# :0 rules...
# f - treat the recipe like a filter and continue down
# w - wait for the exit code of the command
# A - if the last preceding recipe without the `A' or `a' flag matched as
well.
# a - the immediately preceding recipe must have been successfully completed
# ^TO catch all destination specifications containing a specific word.
# ^TO_ catch all destination specifications containing a specific address.
#:0 f
#| formail -fA "x-recipient: $RECIPIENT"
# for dated maildirs
# :0:
# * ^TO_.*galis
# outbox.`/bin/date +%Y`/
:0
* ^Subject:\ RV082\ Security\ Notification
| formail -I "" | sed -e '/^$/d' -e '$!{N;s/\n/ /;}' | grep -v 'sending to
geo@galis.org successfully' | tac >>$HOME/iuxta/XXXXXX/rv082.log ; touch
$HOME/iuxta/XXXXXX/rv082.log
:0
* ^Delivered-To: (geo-iuxta-george-XXXXXX@galis.org|geo-root@ixeon.duo)
|safecat iuxta-XXXXXX iuxta-XXXXXX/new
#####################################################
############## ################
# PRE DELIVERY SECTION
############## ################
#####################################################
:0
# Remove emails marked by the following rule.
* ^X-Loop.*SENT.RSVP.NYSA
|safecat new new/new
:0
# Capture and mark requests to attend meetings and notify attendee
* ^Subject.*AUTO.RSVP.NYSA
| $HOME/bin/rsvp-nysa.sh
:0
* ^TO_nysa@galis.org
| $HOME/bin/rsvp-nysa.sh
#####################################################
############### ####################
# SPAM SECTION
############### ####################
#####################################################
:0
* XXX@stanford.edu
nullbody/
:0
* XXXX-XXXXXX.net
nullbody/
:0
* ^Subject:.Please.update.your.resume.at.XXXXXXXXXXX
/dev/null
################################################## security
:0
* ^Delivered-To:.mailing.list.securesoftware@list.cr.yp.to
|safecat crypto crypto/new
:0 f
* ^Sender:.full-disclosure-bounces@lists.grok.org.uk
#* ^List-Id:.*full-disclosure.lists.netsys.com
| sed -e '/^Subject:.*\[Full-Disclosure\]/s/\[Full-Disclosure\] //g'
:0 a
|safecat full-disclosure full-disclosure/new
:0
* ^TO_bugtraq@securityfocus.com
|safecat security security/new
:0
* ^From:.MAILER-DAEMON@.*(duo|galis.org|iuxta.com)
|safecat new new/new
# filter everything, but flag anything not caught by a filter....
:0
stray/
On Wed, Feb 22, 2023 at 6:18 AM Charles Cazabon <
search-web-for-address@pyropus.ca> wrote:
> Charles Cazabon <search-web-for-address@pyropus.ca> wrote:
> >
> > case "${SENDER}" in
> > 'joe@example.net') to_maildir ./Mail/from-joe/ ;;
> > 'bob@example.org') to_maildir ./Mail/from-bob/ ;;
> > 'foo@example.com' | 'bar@example.com') to_maildir
> ./Mail/example-corp/ ;;
> > *) to_maildir ./Mail/default/ ;;
> > esac
>
> Oh, and after you replace the to_maildir function with a real program
> invocation, make it exec the command, not fork it:
>
> 'joe@example.net') exec getmail_maildir ./Mail/from-joe/ ;;
>
> etc. This is because it's not safe to fork a process to handle the
> message,
> as it could compete with other programs reading the same fd simultaneously.
>
> Charles
> --
> --------------------------------------------------------------------------
> Charles Cazabon
> GPL'ed software available at: http://pyropus.ca/software/
> Read http://pyropus.ca/personal/writings/12-steps-to-qmail-list-bliss.html
> --------------------------------------------------------------------------
>
--
George Georgalis, (415) 894-2710,
http://www.galis.org/