Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. getting MX servers for mail validation

getting MX servers for mail validation

Scheduled Pinned Locked Moved C#
comquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    blakeb_1
    wrote on last edited by
    #1

    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

    H 1 Reply Last reply
    0
    • B blakeb_1

      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

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      I 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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups