Whitelisting a user in Spamassassin

Adding a user to your whitelist gives them a -100 score, which has the effect of always marking their mail as non-spam. To manually whitelist a particular address, say d.cary@sparkingwire.com edit your local user prefs file

vim ~/.spamassassin/user_prefs

or globally

vim /etc/mail/spamassassin/local.cf
# whitelist David Cary:
whitelist_from d.cary@sparkingwire.com

Whitelist and blacklist addresses are file-glob-style patterns, so friend@somewhere.com, *@isp.com, or *.domain.net will all work.

# whitelist everyone at sparkingwire.com:
whitelist_from *@sparkingwire.com

To manually blacklist, use blacklist_from to add an address to your blacklist.

If the sender is at all well known (such as a mailing list), you should use whitelist_from_rcvd instead so that a spammer can’t forge their mail to look like it’s from the whitelisted address. More info on whitelist_from, whitelist_from_rcvd, and blacklist_from is on the web or can be accessed from your local man pages by typing

perldoc Mail::SpamAssassin::Conf.

(you may need to install the perl-doc package to use this program.)

Some good, free web-based tools are available to put a friendly user interface on whitelists (and blacklists) and allow users to edit their own. See WebUserInterfaces.

What is AutoWhitelist?

Another feature of spamassassin is “auto-whitelist”. But the name is a misnomer. The AutoWhitelist is designed as an automatic score averaging system, and is just as likely to penalize or blacklist an address as it is to benefit or whitelist it. If you want to whitelist, you should use the directions above.

Automatically whitelisting people you’ve emailed

To extract a unique list of e-mail addresses from your ‘Sent’ folder (in mbox format), you could use something like this:


rm -f $SADIR/sent_whitelist
for x in `grep "^To:" $SENTMAIL |
grep -o "[[:alnum:]\.\+\-\_]*@[[:alnum:]\.\-]*" |
tr "A-Z" "a-z" |
sort -u` ;

do echo "whitelist_from $x" >> $SADIR/sent_whitelist

cat $SADIR/user_prefs.base $SADIR/sent_whitelist > $SADIR/user_prefs

This can be adapted as necessary, and executed as a cron job. Note, this requires you to store/rename your user_prefs file to user_prefs.base! Make sure you do this before running the script or you’ll lose your preferences. Of course if there is some way I’m not aware of to include files from within a user_prefs file, please someone make the necessary changes.

(There is a way: include filename – Include configuration lines from “filename”. Relative paths are considered relative to the current configuration file or user preferences file.)


I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.