Solved

Validate domain name in an emali account

Posted on 2010-08-13
13
374 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:rubensc
  • 5
  • 4
  • 2
  • +1
13 Comments
 
LVL 5

Expert Comment

by:JayFromPep
ID: 33429715
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
 
LVL 11

Expert Comment

by:ladarling
ID: 33431966
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
 
LVL 5

Expert Comment

by:JayFromPep
ID: 33432111
Sorry, i put it in c#.

But ladarling is right.  Just a simple split and dns check will cover you on it.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 2

Expert Comment

by:DanielBlais
ID: 33446255
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
 

Author Comment

by:rubensc
ID: 33446873
DanielBlais: Thanks for the comment, but I don't plan to use a Shell to execute the command.
0
 
LVL 2

Accepted Solution

by:
DanielBlais earned 125 total points
ID: 33447000
0
 
LVL 11

Expert Comment

by:ladarling
ID: 33447048
Did my previous code not work for you?
0
 
LVL 2

Expert Comment

by:DanielBlais
ID: 33447131
I just noticed your question is on both classic VB and VB.NET.

Can you tell us which language you want.
0
 

Author Comment

by:rubensc
ID: 33457348
I can do both, no problem
Thanks
0
 
LVL 2

Expert Comment

by:DanielBlais
ID: 33457887
So, is there any good solution for you?
0
 

Author Comment

by:rubensc
ID: 33457939
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
 
LVL 2

Expert Comment

by:DanielBlais
ID: 33457977
I agree the .NET solution is the best one.
0
 

Author Closing Comment

by:rubensc
ID: 33719159
I resolve it
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question