getting MX servers for mail validation
-
Hello, I'm trying to implement an e-mail validation program for a large mailing list, and I've run into a few problems. So far, I have code that correctly checks all the syntaxes, and I have code that will check if an address is valid when it is given a list of mail exchanges, however, I can't get my code that actually retrieves the MX servers to work. Does anyone have any code for MX lookup? I found the code I'm currently using at: http://groups.google.com/groups?selm=eMOLVL2WDHA.652%40tk2msftngp13.phx.gbl&oe=UTF-8&output=gplain I can't tell if there is something wrong with the code or if I am just not using it correctly. Here is how I am trying to intialize the DnsLite class:
ArrayList mxRecords = new ArrayList(); //hostname is the domain, such as hotmail.com IPHostEntry IPhst = Dns.Resolve(hostname); DnsLib.DnsLite dnsStruct = new DnsLib.DnsLite(); ArrayList dnsList = new ArrayList(); for(int j = 0; j < IPhst.AddressList.Length; j++) { dnsList.Add(IPhst.AddressList[j].ToString()); } dnsStruct.setDnsServers(dnsList); mxRecords = dnsStruct.getMXRecords(hostname);
This doesn't seem to be working correctly. Does anyone know if this code looks like it should work, or if there is better code examples of MX lookups anywhere that I look at. Thanks, Blake -
Hello, I'm trying to implement an e-mail validation program for a large mailing list, and I've run into a few problems. So far, I have code that correctly checks all the syntaxes, and I have code that will check if an address is valid when it is given a list of mail exchanges, however, I can't get my code that actually retrieves the MX servers to work. Does anyone have any code for MX lookup? I found the code I'm currently using at: http://groups.google.com/groups?selm=eMOLVL2WDHA.652%40tk2msftngp13.phx.gbl&oe=UTF-8&output=gplain I can't tell if there is something wrong with the code or if I am just not using it correctly. Here is how I am trying to intialize the DnsLite class:
ArrayList mxRecords = new ArrayList(); //hostname is the domain, such as hotmail.com IPHostEntry IPhst = Dns.Resolve(hostname); DnsLib.DnsLite dnsStruct = new DnsLib.DnsLite(); ArrayList dnsList = new ArrayList(); for(int j = 0; j < IPhst.AddressList.Length; j++) { dnsList.Add(IPhst.AddressList[j].ToString()); } dnsStruct.setDnsServers(dnsList); mxRecords = dnsStruct.getMXRecords(hostname);
This doesn't seem to be working correctly. Does anyone know if this code looks like it should work, or if there is better code examples of MX lookups anywhere that I look at. Thanks, BlakeI just covered this the other day. You might try searching this forum. There's also an article here about an email validator for ASP.NET that uses Managed C++. It has MX code in there as well (which I mentioned in that previous thread), similar to the same code I used and posted here a while back. See A Managed C++ Email Validator Control for ASP.NET[^]. It's a good article, and the managed code can be translated to any .NET language you like if you truly understand the nature of the .NET Framework (syntax is different, classes, etc. are the same).
Microsoft MVP, Visual C# My Articles