Solved

Validate domain name in an emali account

Posted on 2010-08-13
13
368 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now