Skip to navigation

Maintaining a whitelist of e-mail senders with local mutt and procmail on a server

I run mutt locally on several different computers. OfflineIMAP automatically synchronizes the mailboxes, and that is a huge benefit. But I still had to set up a system that synchronizes my address books and mail settings. I’ve forgotten what exactly I am doing to accomplish this, and I now think there’s a small mistake somewhere that sometimes causes me to lose e-mail addresses from my address book. So I’ll write a little series in the category mail setup to document this on this blog, step by step, as I have time. This is the first instalment.

I maintain a whitelist of e-mail addresses to save spamassassin some work and myself some false positives.
To do this, I have a script that I run periodically (using crontab). The relevant lines of this script are (there’s some more stuff, since I also use it to blacklist things):

#!/bin/bash
ALIASFILE=$HOME/.mutt/.mutt.aliases
WHITELISTMAN=$HOME/.mutt/my_manual_whitelist
WHITELIST=$HOME/.mutt/my_whitelist
grep @ $ALIASFILE | cut -d "<" -f 2  | cut -d ">" -f 1 | grep -v " " > $WHITELIST
cat $WHITELISTMAN >> $WHITELIST
ping -c1 colobus.isomerica.net > /dev/null 2>&1
if [ $? != 0 ] ; then
  exit 0
else
  rsync $WHITELIST isomerica:.procmail/my_whitelist
fi

The script just gets the e-mail addresses from my mutt alias file, combines this with any addresses from a manually maintained alias file, then uploads that to the server. On the server, the spam handling recipe in ~/.procmailrc does not pipe mail from these addresses to spamassassin, but everything else:

 :0fw
* ! ? (echo "$FROM" | $FGREP -f $WHITELIST)
| spamc
:0:
* ^X-spam-flag: yes
$HOME/.maildir/inbox/.Junk/

Comments are closed.