README.md

December 5, 2022 ยท View on GitHub

Email Address Verification

Description

This function verifies that an email address is indeed valid.

This function goes a step further than most other functions I have found online. It allows multi-level domains like subdomain.domain.com.

This function does NOT check for .com .org etc, because you never know what domains will be out there. And even checking for 3 or so characters will die on .tv and .info domains.

More Info

$sEmailAddress = String containing the email address to check

Returns TRUE if the email address is valid

Submitted On
ByJoe Hobbs
LevelIntermediate
User Rating4.6 (23 globes from 5 users)
CompatibilityPHP 3.0, PHP 4.0
CategoryValidation/ Processing
WorldPHP
Archive File

Source Code

// Check to make sure email address is valid
function funcCheckEmail($sEmailAddress)
{
 // Regex of valid characters
 $sChars = "^[A-Za-z0-9\._-]+@([A-Za-z][A-Za-z0-9-]{1,62})(\.[A-Za-z][A-Za-z0-9-]{1,62})+$";
 // Check to make sure it is valid
 $bIsValid = true;
 if(!ereg("$sChars",$sEmailAddress))
 {
  $bIsValid = false;
 }
 return $bIsValid;
}