aspNetIMAP uses the DNS black list (DNSbl) technique to check if a
message is marked as spam. More information on this can be found
here. The following example demonstrates
checking a messages against Spamhaus and Sorbs DNSbl servers.
[C#]
IMAP4 imap = new IMAP4( "127.0.0.1" ); imap.Logger = new IMAPLog(); //if we have write permissions to the filesystem, we can write out a physical log file imap.Logger.Path = "c:\\imap.log"; //if we don't have write permissions to a file, we can always keep an in-memory log imap.Logger.InMemory = true; imap.Username = "dave@blah.com"; imap.Password = "test"; imap.Login(); MailFolder inbox = imap.SelectInbox(); //load the BlackListChecker with 2 databases: spamhaus and sorbs imap.BlackListChecker.AddDNSBlackList( "sbl-xbl.spamhaus.org", "127.0.0.2" ); imap.BlackListChecker.AddDNSBlackList( "dnsbl.sorbs.net", "127.0.0.2, 127.0.0.3, 127.0.0.4, 127.0.0.5, 127.0.0.6, 127.0.0.7, 127.0.0.8, 127.0.0.9, 127.0.0.10, 127.0.0.11, 127.0.0.12" ); //check to see if the first message is spam bool result = inbox.MessageClient.IsBlackListedSpam( 1, IndexType.Ordinal, false ); Console.WriteLine( result ); //write out the log Console.WriteLine( imap.Logger.ToString() ); imap.Disconnect(); Console.WriteLine( "Done" ); Console.ReadLine();
[VB.NET]
Dim imap As New IMAP4("127.0.0.1") imap.Logger = New IMAPLog() 'if we have write permissions to the filesystem, we can write out a physical log file imap.Logger.Path = "c:\imap.log" 'if we don't have write permissions to a file, we can always keep an in-memory log imap.Logger.InMemory = True imap.Username = "dave@blah.com" imap.Password = "test" imap.Login() Dim inbox As MailFolder = imap.SelectInbox() 'load the BlackListChecker with 2 databases: spamhaus and sorbs imap.BlackListChecker.AddDNSBlackList("sbl-xbl.spamhaus.org", "127.0.0.2") imap.BlackListChecker.AddDNSBlackList("dnsbl.sorbs.net", "127.0.0.2, 127.0.0.3, 127.0.0.4, 127.0.0.5, 127.0.0.6, 127.0.0.7, 127.0.0.8, 127.0.0.9, 127.0.0.10, 127.0.0.11, 127.0.0.12") 'check to see if the first message is spam Dim result As Boolean = inbox.MessageClient.IsBlackListedSpam(1, IndexType.Ordinal, False) Console.WriteLine(result) 'write out the log Console.WriteLine(imap.Logger.ToString()) imap.Disconnect() Console.WriteLine("Done") Console.ReadLine()