Solved

Validate domain name in an emali account

Posted on 2010-08-13
13
377 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

691 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