/    Sign up×
Community /Pin to ProfileBookmark

Email Verification Issues

I am creating a newsletter for my client (full story [URL=”https://webdeveloper.com/forum/showthread.php?t=184620″]here[/URL]) and I am having trouble verifying the emails that are added to my list.

Here is my verification code:

[code=php]
//Verify email function
function check_email_address($email1) {
if (!ereg(“^[^@]{1,64}@[^@]{1,255}$”, $email1)) {
return false;
}
$email_array = explode(“@”, $email1);
$local_array = explode(“.”, $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if
(!ereg(“^(([A-Za-z0-9!#$%&’*+/=?^_`{|}~-][A-Za-z0-9!#$%&
&#8618;’*+/=?^_`{|}~.-]{0,63})|(“[^(\|”)]{0,62}”))$”,
$local_array[$i])) {
return false;
}
}
if (!ereg(“^[?[0-9.]+]?$”, $email_array[1])) {
$domain_array = explode(“.”, $email_array[1]);
if (sizeof($domain_array) < 2) {
return false;
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if
(!ereg(“^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|
&#8618;([A-Za-z0-9]+))$”,
$domain_array[$i])) {
return false;
}
}
}
return true;
}
[/code]

Well its not mine, I grabbed it.

I want something easier, some simplified. Also, I need it for 10 different emails (and I don’t want to have to do this 10 different times) Does anyone have any suggestions?

Thanks.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 23.2008 — Assuming PHP version >= 5.2.0:
[code=php]
if(filter_var($email, FILTER_VALIDATE_EMAIL) == false)
{
// invalid email format
}
[/code]

If using an older PHP version:
[code=php]
function is_valid_email_address($email){
$qtext = '[^\x0d\x22\x5c\x80-\xff]';
$dtext = '[^\x0d\x5b-\x5d\x80-\xff]';
$atom = '[^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c'.
'\x3e\x40\x5b-\x5d\x7f-\xff]+';
$quoted_pair = '\x5c[\x00-\x7f]';
$domain_literal = "\x5b($dtext|$quoted_pair)*\x5d";
$quoted_string = "\x22($qtext|$quoted_pair)*\x22";
$domain_ref = $atom;
$sub_domain = "($domain_ref|$domain_literal)";
$word = "($atom|$quoted_string)";
$domain = "$sub_domain(\x2e$sub_domain)*";
$local_part = "$word(\x2e$word)*";
$addr_spec = "$local_part\x40$domain";
return preg_match("!^$addr_spec$!", $email);
}
// usage:
if(is_valid_email_address($email) == false)
{
// invalid email format
}
[/code]
×

Success!

Help @Design-is-BS spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...