Published in: PHP
|
|
|
function is_valid_email($email) { return true; else return false; }
Comments
Subscribe to comments
You need to login to post a comment.
tylerhall on 12/31/69
Website Promotion DIRECTORY is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

175 people have marked this snippet as a favorite
arcturus
Bunker
College
theferf
mrm52
luxuryluke
designerd
katxorro70
FReigM
terriK
px
yuconner
irdial
olive
oronm
NexusRex
ttscoff
clifton
raws
blakeb
Hollow
dmarten
demods
noname
banjomamo
Phoenix
alexd0001
bitcrumb
fael
rich13
edwinjanmoss
vali29
hudge
copyleft
motoroller
dobbshead
marteki
verbal
vilebender
wirjo
adamweeks
madrid
mbcdg
jeff
raptrex
emuman
JimiJay
cschlens
xsubodh
cristianciofu
sosof
SpinZ
Firemarble
dyesin
adamsimms
thebrokenlight
eorwoll
paullorentzen
ibomb
mrjthethird
Arzakon
skywalker
zeusmedia
haozi
romanos
jamarama
Alshie
gAmUssA
mmccrack
stasiaholdren
unabatedshagie
blackabee
shii
dopple
fsorbello
pablodgavilan
jamesming
tikitakfire
jsalo
crashdr
amxm
sumandahal
darkapple
jfherring
oriolfb
hans
Leech
shameel
grassdog
Shocm
Wiederkehr
rubensarrio
ahjo
meetneps
joaosalless
salibaray
iconsis
jackii
baqc
carlosabargues
LostCore
justinscheetz
Hilyin
joelataylor
yuindustries
brother_maynard
vevhlos
elbuenob
PapTom
polarbear
windmarble
matthall
owais
cornellsteven
Anber
willwish
nreliu
irishsk
hamiltonmascioli
Triconium
g0mer
thadwheeler
Zaphod_42
fragmentist
ozone
nb109
delarge
Nanobyte
metallic07039
gripnrip
thatryan
eapen
Blux
JustGreg
obsessivejosh
maxvee8
unitechy
calvingilbert
NyX
joet3ch
aha0617
mailstefsteide
tandouri
GrillPhil
rene-design
zartgesotten
codearachnid
jweagley
KF
Gr33d
Blacksnipe
buk
mattnews
palimadra
kellyrmartin
ruhanirabin
shabbar
debagel
risico
cindreta
vagrantradio
achilles283
ckayra
franverona
portalpie
eivind
metoikos
dfaulty
bradless
jaff
larste
benrudolph
LyndseyPearce
leecsargent
webalienz
Published in: PHP
|
|
|
function is_valid_email($email) { return true; else return false; }
Subscribe to comments
You need to login to post a comment.
The regular expression
[a-zA-Z0-9_-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+
does not compile.
When a dash is used in a character class it indicates a range.
_-. is not a valid range.
A corrected version could be
[.+a-zA-Z0-9_-]+@[a-zA-Z0-9-]+.[a-zA-Z]+
or
[-a-zA-Z0-9_.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+
When the dash is moved to the beginning or end of the character class it is automatically not part of a range and instead does a literal match on the dash character.
Here are my sample scripts:
email_bad.php:
!/usr/bin/php
email_fixed.php:
!/usr/bin/php
Doesn't seem to allow PHP tags. Here's another try on those sample scripts:
Here are my sample scripts:
email_bad.php:
errorreporting( EALL );
function isvalidemail( $email ) { if( pregmatch( "/[a-zA-Z0-9-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email ) > 0 ) return true; else return false; }
$emails = array( 'br0k3n', 'fred_dred@aol.com', 'fred-dred@aol.com', 'fred.dred@aol.com', 'fred+dred@aol.com' );
foreach( $emails as $email ) { echo $email . ' is' . ( isvalidemail( $email ) ? '' : ' not' ) . " valid\n"; }
email_fixed.php:
errorreporting( EALL );
function isvalidemail( $email ) { return pregmatch( '/[.+a-zA-Z0-9-]+@[a-zA-Z0-9-]+.[a-zA-Z]+/', $email ); }
$emails = array( 'br0k3n', 'fred_dred@aol.com', 'fred-dred@aol.com', 'fred.dred@aol.com', 'fred+dred@aol.com' );
foreach( $emails as $email ) { echo $email . ' is' . ( isvalidemail( $email ) ? '' : ' not' ) . " valid\n"; }
Simplest way. PHP5 only
http://www.w3schools.com/php/filtervalidateemail.asp
http://snipplr.com/view/8844/rfc822-compliant-email-address-validator/
http://snipplr.com/view/11616/rfccompliant-email-address-validator/
And check out a head-to-head of free validators here: http://www.dominicsayers.com/isemail/
From w3schools - http://www.w3schools.com/php/filtervalidateemail.asp
To check whether an email address actually exists on the mailserver, use the [PHP SMTP Email Validation][1] class.
[1] http://code.google.com/p/php-smtp-email-validation/ "PHP SMTP Email Validation"
The correct link:
To check whether an email address actually exists on the mailserver, use the PHP SMTP Email Validation class.
Simplified reg ex for this: /\S+@\S+.\D+/
Try this: validemail.org
Here is another SMTP mail validation function in php: http://snipplr.com/view/25505/validate-emails-with-smtp-and-php/
You can try the next: function checkemailaddress($email) { // First, we check that there's one @ symbol, // and that the lengths are right. if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters // in one section or wrong number of @ symbols. return false; } // Split it into sections to make life easier $emailarray = explode("@", $email); $localarray = explode(".", $emailarray[0]); for ($i = 0; $i < sizeof($localarray); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^
{|}~-][A-Za-z0-9!#$%& ↪'*+/=?^_{|}~.-]{0,63})|(\"[^(\|\")]{0,62}\"))$", $localarray[$i])) { return false; } } // Check if domain is IP. If not, // it should be valid domain name if (!ereg("^[?[0-9.]+]?$", $emailarray[1])) { $domainarray = explode(".", $emailarray[1]); if (sizeof($domainarray) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domainarray); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])| ↪([A-Za-z0-9]+))$", $domainarray[$i])) { return false; } } } return true; }Also you can search for demo email php form and look a right code