Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: [Original edit by AlexAndr] fix grep pattern: dash is special in [], ._+ are not special in[], + is better than * and requires -E, [:alnum:] accepts national letters, which is wrong

...

No Format
#!/bin/sh

SADIR=~/.spamassassin
SENTMAIL=~/mail/Sent

rm -f $SADIR/sent_whitelist
for x in `grep "^To:" $SENTMAIL |
	grep grep -oEio "[[:alnum:]\.\+\-\_]*@[[:alnum:]\.\-]*"'[-a-z0-9.+_]+@[-a-z0-9.]+' |
	tr "A-Z" "a-z" |
	sort -u` ;
	
	do echo "whitelist_from $x" >> $SADIR/sent_whitelist
done

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.

...