|
-
Jan 8th, 2008, 04:17 PM
#1
[RESOLVED] Email validation code
Anyone have any good code or links for validating an email address?
Thanks
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 8th, 2008, 05:26 PM
#2
Re: Email validation code
-
Jan 8th, 2008, 06:16 PM
#3
Re: Email validation code
Thanks but I know google. Im looking more for known solid code.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 8th, 2008, 07:32 PM
#4
Re: Email validation code
Look at my sig. I have an AJAX tutorial - one of the examples is email verification. The code can also be applied in a no dynamic environment too.
-
Jan 8th, 2008, 07:35 PM
#5
Re: Email validation code
In the code. I.e: to validate the best you can do is:
- A regular expression.
- A look up on the domain name to verify it exists.
The best way and only way to be sure is to verify. Validation and verification are both desirable in a two staged approach.
-
Jan 8th, 2008, 07:38 PM
#6
Re: Email validation code
 Originally Posted by RobDog888
Thanks but I know google. Im looking more for known solid code.
And what exactly do you mean by "solid" code? Google is the best place to find some of the regular expressions and libraries out there which can and are being used. Why re-invent the wheel?
-
Jan 9th, 2008, 12:57 AM
#7
Re: Email validation code
Thanks, the articles examples should help but I just need the email validation of a correct format entry. No return email sending needed.
Regex is fine and about all I need but what is the syntax needed?
I already have captcha verification to prevent spammers too.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 9th, 2008, 02:33 AM
#8
Re: Email validation code
The proper regular expression to validate an email address is approximately the length of War and Peace and is thus completely inefficient.
I take the view that as long as it contains one '@' symbol it is highly statistically likely to be valid and at that point one should verify it by sending a confirmation message containing an activation code.
-
Jan 9th, 2008, 02:43 AM
#9
Re: Email validation code
I usually check for an @ symbol and at least one a-z0-9_ and at least one dot in the domain.
-
Jan 9th, 2008, 02:50 AM
#10
Re: Email validation code
Gimme c0d for it containing an "@" and a "." and minimum length of 8 
Gimme, gimme, gimme c0d, gimme c0d ...
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 9th, 2008, 02:55 AM
#11
Re: Email validation code
You don't deserve this but:
/.+@[a-z0-9_](.[a-z0-9_])+/i
To be used with preg_match.
-
Jan 9th, 2008, 03:10 AM
#12
Re: Email validation code
 Originally Posted by visualAd
I usually check for an @ symbol and at least one a-z0-9_ and at least one dot in the domain.
a@b is a valid address...
-
Jan 9th, 2008, 03:14 AM
#13
Re: Email validation code
-
Jan 9th, 2008, 03:18 AM
#14
Re: Email validation code
-
Jan 9th, 2008, 03:23 AM
#15
Re: Email validation code
Requiring a FDN is perfectly acceptable if your application is designed for external users. Because what the validation is doing is detecting human error, nothing more; nothing less. It is quite likely that if the domain name is not fully qualified and the site is designed for external users that the user has made a mistake.
-
Jan 9th, 2008, 03:32 AM
#16
Re: Email validation code
 Originally Posted by visualAd
You don't deserve this but:
/.+@[a-z0-9_](.[a-z0-9_])+/i
To be used with preg_match.
Why not
Shouldnt the minimum valid format be "[email protected]"? Minimum 7 characters?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 9th, 2008, 03:35 AM
#17
Re: Email validation code
[email protected] will match that regular expression.
What's the problem?
-
Jan 9th, 2008, 03:36 AM
#18
Re: Email validation code
 Originally Posted by visualAd
Requiring a FDN is perfectly acceptable if your application is designed for external users. Because what the validation is doing is detecting human error, nothing more; nothing less. It is quite likely that if the domain name is not fully qualified and the site is designed for external users that the user has made a mistake.
Better.
However I would still rather verify than attempt to validate the address. If you can send a verification email then validation is of course unnecessary.
 Originally Posted by RobDog888
[email protected], if you require a TLD. Not all are three characters; China, for example, is simply .cn.
-
Jan 9th, 2008, 03:37 AM
#19
Re: Email validation code
you said I dont desreve it 
So thats the regex but how about this prego_match function? Is it a php built in function?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 9th, 2008, 03:40 AM
#20
Re: Email validation code
 Originally Posted by RobDog888
So thats the regex but how about this prego_match function? Is it a php built in function?
I believe that is a Spears family function.
However, you may be looking for preg_match.
-
Jan 9th, 2008, 03:41 AM
#21
Re: Email validation code
What would be "[email protected]" then? ".a" stands for a real country extension or is the minimum country length is 2?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 9th, 2008, 03:44 AM
#22
Re: Email validation code
What the heck is all the complication with the Spears function? PREG_OFFSET_CAPTURE? I just want to regex the string to see if its a valid string or not. I just cant get into this php code.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 9th, 2008, 03:48 AM
#23
Re: Email validation code
Like this? 
PHP Code:
$pattern = '/.+@[a-z0-9_](.[a-z0-9_])+/i';
preg_match($pattern, txtEmail, $matches, PREG_OFFSET_CAPTURE);
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 9th, 2008, 03:50 AM
#24
Re: Email validation code
 Originally Posted by RobDog888
What would be " [email protected]" then? ".a" stands for a real country extension or is the minimum country length is 2?
It's not real (at the moment) but I don't believe there is a minimum length.
You could try RFC1034, if you can be bothered.
Also, for entertainment purposes, here is a regular expression to validate addresses against RFC822:
http://ex-parrot.com/pdw/Mail-RFC822-Address.html
-
Jan 9th, 2008, 03:54 AM
#25
Re: Email validation code
 Originally Posted by RobDog888
Like this?
PHP Code:
$pattern = '/.+@[a-z0-9_](.[a-z0-9_])+/i';
preg_match($pattern, txtEmail, $matches, PREG_OFFSET_CAPTURE);
Yes, except most of the parameters are unnecessary.
PHP Code:
if (preg_match('/.+@[a-z0-9_](.[a-z0-9_])+/i', $address) === 1) { # Valid. } else { # Invalid. }
-
Jan 9th, 2008, 03:57 AM
#26
Re: Email validation code
Isnt there some utility or site that generates regex patterns?
What does the offset constant signify other then some kind of lame offset?
What should it be then to shorten it to just the necessary chars?
Thanks for the help so far guys
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 9th, 2008, 06:47 AM
#27
Re: Email validation code
The validation and verification are necessary if you want to ensure the email address is correct.
I use a utility called the brain to generate regular expressions - I won't tell you whose brain though 
Although PHP does have a good guide to PCRE - http://us3.php.net/manual/en/referen...ern.syntax.php
-
Jan 9th, 2008, 06:50 AM
#28
Re: Email validation code
In addition you need to use the ^ and $ assertions to anchor the email address to the beginning and end of the string respectively otherwise you could have something like this go though:
Code:
i am a naughty mistress & love to sell 100TB HD'[email protected] house.
'/^.+@[a-z0-9_](.[a-z0-9_])+$/i'
-
Jan 9th, 2008, 02:04 PM
#29
Re: Email validation code
If I have them enter in their email twice in separate textboxes, do comparisions that they match and verify the correct email format then that should be enough (at least for now).
Ps, where can I download "brain" for generating regex?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 9th, 2008, 02:44 PM
#30
Re: Email validation code
They are really not as scary as they look. My point is the best person to generate a regular expression is you - as it is like a template for a string you need to create a regular expression to test for compliance to that format.
The best option is to Google and find out if anyone has written one already - if not you are on your own.
-
Jan 10th, 2008, 03:56 AM
#31
Re: Email validation code
I have this code in the regex sucessful match block but I am getting a parse error 
PHP Code:
mail(
webmaster@example.com,
"Something for the subject",
"Email - ".$_POST['txtEmail1']."\r\n".
$_POST['txtMessage']."\r\n\r\n".
"Contact message from website.",
"From: noreply@{$_SERVER['HTTP_HOST']}\r\n"
);
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 10th, 2008, 05:04 AM
#32
Re: Email validation code
It's commonplace to put quotes around strings.
-
Jan 10th, 2008, 03:31 PM
#33
Re: Email validation code
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 10th, 2008, 05:14 PM
#34
Re: Email validation code
solved it. I needed the curly braces around the post functions.
Code:
"{$_POST['txtMessage']}\r\n\r\n"
Thanks everyone!
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|