0 votes
by (120 points)

Dear Sir/Madam,

How can I filter spam or junk mail from my registered mail account.(there are about 30 mail and 80 junk mail) .I want to able to get just only mails except junk,spam mails. Pop3MessageCollection pop3Messages = _pop.GetMessageList();

Thanks br, Unsal Donmez

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (70.3k points)

Please note the Rebex Mail for .NET doesn't include any junk/spam filtering. It is designed to work with remote mail account, not to detect and filter spam. However if your registered mail account includes some kind of spam assassin, you can receive and process mail headers yourself.

For example headers can look like this:

X-Spam-Flag: YES
X-Spam-Status: Yes, score=33.3 required=6.9 tests=BAYES_99,DOS_OE_TO_MX,
    URIBL_SC_SURBL,URIBL_WS_SURBL autolearn=spam version=3.3.1
X-Spam-Report: *  3.5 BAYES_99 BODY: Bayes spam probability is 99 to 100%
    *      [score: 1.0000]

To receive and process headers you can use code similar to this one:

Pop3 pop = new Pop3();
// connect and login ...

// receive mail headers
Pop3MessageCollection list = pop.GetMessageList(Pop3ListFields.FullHeaders);
foreach (Pop3MessageInfo info in list)
    // check if 'x-spam-flag' is present and contains 'YES'
    if (info.Headers["x-spam-flag"] != null && 
        info.Headers["x-spam-flag"].Value.ToString() == "YES")

    // do something with mail info