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.


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( "", "" ); blc.AddDNSBlackList( "", ",,,,,,,,,," ); return blc; }


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("", "") blc.AddDNSBlackList("", ",,,,,,,,,,") Return blc End Function 'CreateChecker