Retrieves the list of domain names for the specified IP address.
The array of strings taken from DNS PTR data for the specified IP address, or a null reference (Nothing in Visual Basic) if an error occurred or no PTR record found for the given domain.
This method makes DNS PTR query (reverse DNS query) to the servers listed in DnsServers collection regarding ipString address.
Popular anti-spam check is making reverse DNS query for the IP address from which the mail message was sent. Then, the retured domain name is compared with the domain name from "From:" or "Return-Path:" address to make sure it was really sent from that domain.
Note If the IP address has multiple domain names associated with it, PTR record will usually return only the domain name taken from A record. Other domain names are aliases (CNAMEs). They will not be returned as their information is not contained in PTR records.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidArgumentException | ipString is a null reference (Nothing in Visual Basic). |
| MailBeeException | An error occurred and ThrowExceptions is true. |
This sample retrieves domain names associated with an IP address. Make sure to specify real IP address prior to running this sample.
[C#] using System; using MailBee; using MailBee.SmtpMail; class Sample { static void Main(string[] args) { Smtp mailer = new Smtp(); mailer.DnsServers.Autodetect(); string[] domains = mailer.GetPtrData("123.123.123.123"); foreach (string domain in domains) { Console.WriteLine(domain); } } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.SmtpMail Class Sample Shared Sub Main(ByVal args() As String) Dim mailer As Smtp = New Smtp mailer.DnsServers.Autodetect() Dim domains() As String = mailer.GetPtrData("123.123.123.123") Dim domain As String For Each domain In domains Console.WriteLine(domain) Next End Sub End Class
Smtp Class | MailBee.SmtpMail Namespace | GetMXHosts | GetTxtData