RblFilter Constructor
Creates an instance of RblFilter class.

Namespace: MailBee.AntiSpam
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
Syntax
public RblFilter()
Exceptions
ExceptionCondition
MailBeeLicenseExceptionMailBee.NET AntiSpam not licensed.
Remarks
This overload requires the license key be already set (such as with MailBee.Global.LicenseKey property, app.config, web.config, or in Windows registry).
Examples

This sample checks an e-mail against popular RBLs (the e-mail is loaded from a file but could also be received from a mail server, the only requirement is that the message must have Received header from which MailBee will determine the IP address the message originated from).

The sample also fine-tunes DNS checking routine for better performance (at cost of lower accuracy). You can remove "For performance sake" section to return to default DNS settings.

This is single-threaded version of the sample from RblFilter topic. It will take longer to execute but easier to debug because execution order is simple and determined.

using System;
using MailBee;
using MailBee.Mime;
using MailBee.DnsMX;
using MailBee.AntiSpam;

class Sample
{
    static void Main(string[] args)
    {
        RblFilter rbl = new RblFilter();

        // Logging is helpful for debugging.
        rbl.Log.Enabled = true;
        rbl.Log.Filename = @"C:\Temp\log.txt";
        rbl.Log.Clear();

        // RBL check needs DNS servers.
        rbl.DnsServers.Autodetect();

        // For performance sake, avoid making redundant TCP queries. UDP is enough with RBL.
        // Also, the default 5000ms timeout can be too long.
        foreach (DnsServer dns in rbl.DnsServers)
        {
            dns.TryTcp = false;
            dns.UdpTimeout = 500;

            // Or you can leave UdpRetryCount=2 (default), it will end up in increased times to check against dead/slow RBLs
            // but the results will be more accurate.
            dns.UdpRetryCount = 1;
        }

        // Grab some mail message to check. In production, you can get it from IMAP server or elsewhere.
        MailMessage msg = new MailMessage();
        msg.LoadMessage(@"C:\Temp\msg.eml");

        // Ask some popular RBLs about this message.
        RblStatusCollection statuses = rbl.GetRblStatusesOfMailOriginatingIPAddress(msg, 0,
            new string[] { "zen.spamhaus.org", "bl.spamcop.net", "cbl.abuseat.org" });
        if (statuses == null)
        {
            Console.WriteLine("Can't extract originating IP address from the e-mail");
        }
        else
        {
            Console.WriteLine("Is in RBLs: " + statuses.IsInRbls.ToString());
            foreach (RblStatus status in statuses)
            {
                Console.WriteLine(string.Format("RBL: {0}, IP found: {1}, RBL check resulted in error: {2}, RBL reply: {3}",
                    status.RblHost, status.IsIPAddressInRbl, status.IsError, status.RblReplyText));
            }
        }
    }
}
See Also