RblFilterGetRblStatusesOfIPAddress Method
Gets the statuses of the given IPv4 address in the specified RBLs.

Namespace: MailBee.AntiSpam
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
public RblStatusCollection GetRblStatusesOfIPAddress(
	string ipString,
	string[] rblHosts
)

Parameters

ipString
Type: SystemString
The IPv4 address to check, as "11.22.33.44" string.
rblHosts
Type: SystemString
The array of DNS RBLs' host names.

Return Value

Type: RblStatusCollection
The collection of statuses of the given IPv4 address in the specified RBLs.
Exceptions
ExceptionCondition
MailBeeInvalidArgumentExceptionipString is a null reference (Nothing in Visual Basic) or an empty string or does not denote a valid IPv4 address or rblHosts is a null reference or contains at least one value which is a null reference or an empty string.
MailBeeExceptionAnother error occurred (e.g. timeout from DNS server) for all RBLs in the list.
Remarks

This method supports multi-threading to check multiple RBLs at once. To enable multi-threading, set MaxThreadCount to -1.

For each RBL, its own status is set. Unlike Boolean-returning methods like IsIPAddressInRbl(String, String), this method provides more extensive info for an IP address. In particular, RblReplyText property of each RblStatus object in the resulting collection may contain the exact reason of the IP addresses being blacklisted. You need to refer to the documentation of the corresponding RBL to find out how to treat the return codes.

For instance, return codes of the popular Spamhaus Zen RBL can be found at https://www.spamhaus.org/zen/.

Note Note
This method won't throw an exception if only certain RBLs in the list failed to be checked. If at least one DNS query succeeded, the method will return normally. For RBLs which failed, IsError will be true. To monitor errors during this method's execution, subscribe to ErrorOccurred event.
Examples
using System;
using MailBee;
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.Format = LogFormatOptions.AddContextInfo;
        rbl.Log.Clear();

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

        // For performance sake, avoid making redundant 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;
        }

        // Multi-threading lets us check all RBLs at once.
        rbl.MaxThreadCount = -1;

        // Ask some popular RBLs about some IP address.
        RblStatusCollection statuses = rbl.GetRblStatusesOfIPAddress("11.22.33.44",
            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