townlist/procmailrc

57 lines
1.2 KiB
Plaintext

# mailing list protocol!
# depends on a bunch of files in $HOME/lists --
# a "listname.users" containing all of the users
# and (optionally) a "listname.senders" if you want to restrict that
SHELL=/bin/sh
SENDMAIL=/usr/sbin/sendmail
LINEBUF=10000000
:0
* ^To:.*list\+\/[a-z0-9_]+@tilde\.town
LIST=| echo "$MATCH" | sed 's/@.*//' | sed 's/\(.\{16\}\).*/\1/' | tr '[:upper:]' '[:lower:]'
:0A
{
:0A
* ? [ -e ${HOME}/lists/${LIST}.users ]
RECIPIENTS=| cat ${HOME}/lists/${LIST}.users | tr '\n' ' '
:0E
{ RECIPIENTS="" }
}
# Extract envelope sender. Email addresses are actually very complex
# but we're on tilde.town so our email addresses aren't going to have spaces
:0A
* ^From \/[^ ]*
ENV_SENDER=|echo "$MATCH" | sed "s/ .*//"
:0A
ENV_USER=|echo "$ENV_SENDER" | sed "s/@.*//"
:0A
{
# If we have a restricted list of senders we should abort if it's not in there
:0A
* ? [ -e "${HOME}/lists/${LIST}.senders" ]
{
:0A
* !? grep -F "${ENV_USER}" "${HOME}/lists/${LIST}.senders"
# hack to quit procmailrc immediately (WHY)
{ EXITCODE=77 HOST= }
}
}
:0Af
| formail -a "X-Loop: list+${LIST}@tilde.town" -I "Reply-To: ${LIST} <list+${LIST}@tilde.town>" -I "From: ${ENV_SENDER}"
:0A
{
UMASK=003
:0c:
archive/${LIST}
}
:0A
! ${RECIPIENTS}