Solved

Validate email address on MFC dialog

Posted on 2004-04-09
4
998 Views
Last Modified: 2013-11-20
I am storing email address in my database & mails will be sent to them automatically.
User can specify email address in text box of MFC dialog. I would like to know is there any validation i can do for the same like javascript validation.
0
Comment
Question by:amlooks
4 Comments
 
LVL 11

Accepted Solution

by:
KurtVon earned 50 total points
ID: 10791215
The only way to validate an email address is to email to it and wait for a reply.  Spammers would probably love some sort of automated validation, but it doesn't exist or they would be using it for harvesting purposes.

You can, however make sure the email address is in a valid format.  It should contain only one @, have text before and after that, and the text after should be a valid domain name.  Valid domain names have at least one ".", and conatian only alphanumerics and the "-" character.

Hope this helps.
0
 
LVL 14

Expert Comment

by:wayside
ID: 10792081
You can do a lookup on the domain name to make sure it is a valid domain (use gethostbyname() for example).

Ths can be a lengthy operation depending on how good your access to the names server is.
0
 
LVL 4

Expert Comment

by:bkfirebird
ID: 10794580
I faced a similar problem before and tried looking up host name,etc but it turned out to be too wasteful. Instead I just checked for the following pattern xxxxx@xxxx.tld where tld was a from a list of common top level domains that i statically declared.

-Kiran Adigopula
0
 
LVL 5

Expert Comment

by:Nass89
ID: 10795709
Hi,
If you want to check the format of Emai l address use:

char Address_String[], Name[], Domain[], Ext[];
sscanf(Address_String, "%s@%s.%s", Name, Domain, Ext);

and check each field to validate it.

If you want to find, if it is a valid Email, KurtVon has stated it.

Good Luck!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

791 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