Validate domain name in an emali account

Hi: We want to be able to validate the domain name of an email account when user input this value in our webpage, in short terms we want to accomplish the following scenerio:
user type->: myaccount@anygivendomainname.com
our routine checks for anygivendomainname.com and check if it really exists, if not then we can inform customer and she/he can double check the field value
Thanks
rubenscAsked:
Who is Participating?
 
DanielBlaisConnect With a Mentor Commented:
0
 
JayFromPepCommented:
There are a ton of answers for this.

You can do some pretty cool stuff with System.net.dns that will allow you to check with some dns servers to make sure the domain is a valid domain.

I.E.....

IPHostEntry hostInfo = Dns.GetHostByName("www.contoso.com");

You can also use 3rd party stuff.

here is a link to a topic that touches on just this.

http://www.velocityreviews.com/forums/t81340-dns-lookup-from-net-validate-email-address-domain.html
0
 
ladarlingCommented:
This is an example of splitting the email address apart and checking it with a host lookup:
(The split will put place the username in index 0 and the domain in index 1 of a string array)
 

Dim anEmailAddress As String = "somebody@somewhere.com"
        Dim mailParts() As String = Split(anEmailAddress, "@")
        Dim hostIP As Net.IPHostEntry = Net.Dns.GetHostEntry(mailParts(1))
        If Not IsNothing(hostIP) Then
            MsgBox("DNS found the domain name: " & hostIP.HostName)
        Else
            MsgBox("Not a valid domain:" & hostIP.HostName)

        End If

Open in new window

0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
JayFromPepCommented:
Sorry, i put it in c#.

But ladarling is right.  Just a simple split and dns check will cover you on it.
0
 
DanielBlaisCommented:
In VB6 application, I don't know how to do this.  You can use the NSLOOKUP command line tool.

Call this line and get back the result in .txt file.
nslookup.exe -type=MX somewhere.com > nslookup.txt

Open in new window

0
 
rubenscAuthor Commented:
DanielBlais: Thanks for the comment, but I don't plan to use a Shell to execute the command.
0
 
ladarlingCommented:
Did my previous code not work for you?
0
 
DanielBlaisCommented:
I just noticed your question is on both classic VB and VB.NET.

Can you tell us which language you want.
0
 
rubenscAuthor Commented:
I can do both, no problem
Thanks
0
 
DanielBlaisCommented:
So, is there any good solution for you?
0
 
rubenscAuthor Commented:
I will prefer ASP.NET, the thing with the cmdshell (nslookup) it's external and asyncronous, we are testing the Net.Dns.GetHostEntry stuff, any other idea?
Regards
0
 
DanielBlaisCommented:
I agree the .NET solution is the best one.
0
 
rubenscAuthor Commented:
I resolve it
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.