Tips for mailing list subscibers
sorting mail with Mail Avenger

If you subscribe to many mailing lists, it is often useful to deliver each mailing lists to a separate mailbox, so as to keep your main mailbox as free of clutter as possible.

In addition, the fact that you subscribe to one mailing list does not necessarily mean you want to be subscribed to other lists; yet currently it is all too easy for your email address to leak out and be added to other lists without your permission.

The solution to both problems is easy, if you have avenger.local(8) configured on your system. You can simply subscribe to different mailing lists under different addresses, and deliver the different addresses to different mailboxes. To prevent further use of your address by different mailing lists, you can restrict use of list-specific addresses to particular senders.

These examples all assume that you have hooked avenger.local(8) into your MTA, and that your Separator character is +.

Simple sorting based on recipient

Let's say you want to subscribe to one or more mailing lists about email, and deliver them to a maildir called ./Mail/.lists.email/. Create a file called $HOME/.avenger/rcpt+lists+default containing the following line:
test -f "local+lists+$SUFFIX" || reject unknown user
Now place the following in $HOME/.avenger/local+lists+email:
! echo "./Mail/.lists.$EXT1"
Now you can subscribe to the mailing lists under address yourlogin+lists+email@your.host.com. To create another address, you can link this file to something else (e.g., ln ~/Mail/local+lists+email ~/Mail/local+lists+party).

To restrict to a particular sender, you can create a specific $HOME/.avenger/rcpt+lists+email file, with something like this:

test MALING.LIST.HOST = "$SENDER_HOST" \
    || reject "<$SENDER>.. unauthorized sender"

case "$SPF" in
    neutral|none)
        spf ESPF mx/24 a/24 ptr -all
        setvars
        ;;
    *)
        ESPF="$SPF"
        ;;
esac

case "$ESPF" in
    pass)
        accept mailing list ok
        ;;
    error)
        defer temporary error in DNS processing
        ;;
    *)
        reject could not authenticate client \
            "$CLIENT_IP" for "$SENDER_HOST"
        ;;
esac

Lists hosted by Mailman

One often wishes to subscribe to a number of mailing lists on the same server, all run by Mailman. Unfortunately, Mailman makes it much more convenient to subscribe to all lists under the same email address.

Fortunately, even if you are subscribed to multiple mailing lists on the same server, it is easy to demultiplex messages based on the sender address. For example, all traffic coming from mailing list list@host.com will generally come from one of three envelope sender addresses:

By extracting list from the envelope sender, you can deliver all mail to list into a mailbox named ~/Mail/.server.list. To do so, create a file ~/.avenger/lists/server with the following three lines:
*-bounces@host.com
*-admin@host.com
*-owner@host.com
Now create the following script in ~/.avenger/scripts/getlist:
#!/bin/sh

listdir="$HOME/.avenger/lists"

server="${SUFFIX%%+*}"
if match -n -1 '*[./]*' "$server"; then
    echo invalid user
elif test ! -f "$listdir/$server"; then
    echo unknown user
elif list=`match -n 1 -f "$listdir/$server" "$SENDER"`; then
    echo "$server.$list"
    exit 0
else
    echo unauthorized sender
fi
exit 67
Make the script executable by running the command chmod +x ~/.avenger/scripts/getlist. Next, create a file ~/.avenger/local+lists+default, with the following line:
! out=`$HOME/.avenger/scripts/getlist` && echo "./Mail/.$out/"
Now create a file ~/.avenger/rcpt+lists+default with the following:
if test ! -f "local+lists+$SUFFIX"; then
    out=`./scripts/getlist` || reject "$out"
fi

case "$SPF" in
    neutral|none)
        spf ESPF mx/24 a/24 ptr -all
        setvars
        ;;
    *)
        ESPF="$SPF"
        ;;
esac

case "$ESPF" in
    pass)
        accept mailing list ok
        ;;
    error)
        defer temporary error in DNS processing
        ;;
    *)
        reject could not authenticate client \
            "$CLIENT_IP" for "$SENDER_HOST"
        ;;
esac
Now you can subscribe to any mailing list on the server under address yourlogin+lists+server@your.host.com.

Yahoo groups

If you wish to subscribe to Yahoo groups, then as with Mailman, it is simplest if you can subscribe to all groups under the same address. Yahoo group mail comes from an envelope sender that looks like this:
    sentto-NNN-xxx-xxx-user=host@returns.groups.yahoo.com
Here, NNN is a number that uniquely identifies the group. You can pull these numbers out of the Return-Path headers of the mail messages, and list them in a directory ~/.avenger/yahoo, so that, for example, the file ~/.avenger/yahoo/3388489 contains a single line with "nyhappenings" (because NNN=3388489 corresponds to the nyhappenings group). Now create a script ~/.avenger/scripts/getyahoo with the following:
#!/bin/sh

yahoo="$HOME/.avenger/yahoo"
pref=./Mail/.yahoo.

if ! groupno=`match -rn1 'sentto-*-*' "$SENDER"` \
        || match -n -1 '*[./]*' "$groupno" \
        || ! groupname=`cat "${yahoo}/${groupno}"`; then
    echo "${nnmlpref}unknown/"
else
    echo "${nnmlpref}${groupname}/"
fi
Make the script executable by running the command chmod +x ~/.avenger/scripts/getyahoo. Next, create a ~/.avenger/local+lists+yahoo file with:
! $HOME/.avenger/scripts/getyahoo
Finally, create a ~/.avenger/rcpt+lists+yahoo with:
match -n -1 '*[.@]yahoo.com' "@$SENDER_HOST" \
    || match -n -1 '*[.@]yahoo-*.com' "@$SENDER_HOST" \
    || reject "unauthorized sender"

case "$SPF" in
    neutral|none)
	spf ESPF ptr:yahoo.com -all
	setvars
	;;
    *)
	ESPF="$SPF"
	;;
esac

case "$ESPF" in
    pass)
	accept yahoo mailing list ok
	;;
    error)
	defer temporary error in DNS processing
	;;
    *)
	reject could not authenticate client "$CLIENT_IP" for "$SENDER_HOST"
	;;
esac
Now you can subscribe to yahoo groups under address yourname+lists+yahoo@your.host.com.

<<< Back to Tips page