This is easily achieved using SpamAssassin. (You would also need something like Mail::Audit or procmail to do the folders by sender part.)

SpamAssassin is built arround the notion of "tests" which are applied to each msg. Each test has an asociated point value, and if the total point value for a particular msg is above a set threshold, the msg is considered spam. Which tests you use, what point values each test should get, and what your personal threshold are is totally configureable.

(Aside: SpamAssassin marks up your msgs indicating which are spam by adding Mime Headers listing which tests it pased and what it's total score was, in addition to putting "spam" in the subject. All of which makes it easy to set up automatic filtering (again, this is all configurable)

One of the tests is called "USER_IN_WHITELIST" with a default score of "-100" (ie: if the user is in your whitelist, they have to do a LOT of bad shit in their emails to be considered spam). If you configure SpamAssassin to only use the USER_IN_WHITELIST test, and set your personal threshold at -99, email from anyone you don't know will get flagged as spam (and you can have Mail::Audit or procmail file it into a spam folder for you.)

The only step left is to periodicly check your spam folder for mesgs from people who are "ok" but have never been added to your whitelist -- that's easy enough. the -W option of spamassassin will parse a msg for addresses and add them all to your whitelist, Or if your email program allows you to hook into perl methods, the Mail::SpamAssassin API has methods like add_all_addresses_to_whitelist.


In reply to Re: Re: Email filtering by hossman
in thread Email filtering by John M. Dlugosz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.