Checking for Spam
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#]

static void Main(string[] args) { string licenseFile = "c:\\aspNetPOP3.xml.lic"; POP3.LoadLicenseFile( licenseFile ); POP3 p = new POP3( true, false ); p.BlackListChecker = CreateChecker(); p.Connect(); //check to see if the message is spam bool result = p.CheckBlackList( 0 ); p.Disconnect(); Console.WriteLine( "Message 0 is considered spam: {0}", result ); Console.WriteLine( "done." ); Console.ReadLine(); } static BlackListChecker CreateChecker() { BlackListChecker blc = new BlackListChecker(); //add a few DNSbl servers blc.AddDNSBlackList( "sbl-xbl.spamhaus.org", "127.0.0.2" ); blc.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" ); return blc; }


[VB.NET]

Public Overloads Shared Sub Main() Dim licenseFile As String = "c:\aspNetPOP3.xml.lic" POP3.LoadLicenseFile(licenseFile) Dim p As New POP3(True, False) p.BlackListChecker = CreateChecker() p.Connect() 'check to see if the message is spam Dim result As Boolean = p.CheckBlackList(0) p.Disconnect() Console.WriteLine("Message 0 is considered spam: {0}", result) Console.WriteLine("done.") Console.ReadLine() End Sub 'Main Shared Function CreateChecker() As BlackListChecker Dim blc As New BlackListChecker() 'add a few DNSbl servers blc.AddDNSBlackList("sbl-xbl.spamhaus.org", "127.0.0.2") blc.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") Return blc End Function 'CreateChecker