Checking the format of an email address

Last update on December 21, 2008 08:36 AM by jak58
Published by jak58

Checking the format of an email address





Here below you chould find sp techniques to determine if a variable contains a valid email address.

Using a filter


Using these type of fuction, you can check if email address is valid.
filter_var ()
Example:

if(filter_var($email, FILTER_VALIDATE_EMAIL)){
    //Email is good
}

Using regular expressions


With regular expressions, it is possible to check if an email address, obtained via a form, is valid.

Here is a function that checks if a string is only an e-mail address valide.function VerifierAdresseMail ($ address)

function VerifyMailAddress($address)
{
   $Syntax='#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$#';
   if(preg_match($Syntaxe,$adrdess))
      return true;
   else
     return false;
}

Implementation


After getting the address a form:

$address=htmlentities($_POST['adress']);
if(VerifyMailAddress($adress))
  echo '<p>Your address is valid.</p>';
else
  echo '<p>Your address is not valid.</p>';
Best answers for « Checking the format of an email address » in :
Obtaining a disposable email address Show Kasmail Spambox Jetable mail Enterto spamless email Yopmail Firefox extension Obtaining a disposable email address A disposable email is an e-mail service enabling you to send and receive mail for a short period. This practice is...
Verify and e-mail address format ShowVerify and e-mail address format Using a filter With regular expressions Example of use Explanations What does the code do There are several ways to determine if a variable contains a valid email address. These techniques do not...
False professional email addresses ShowFalse professional email addresses An opportunity for scammers Avoiding the trap Here is a non exhaustive list domain names used frequently by scammers An opportunity for scammers An address in the form bank@financial.com or...
E-mail Address Not Verified Show[E-mail Address Not Verified] is displayed next to the username Introduction Configure your email address so that it works on MSN Messenger Introduction When you use MSN Messenger or Windows Live Messenger with an address not...
Download Email Address Extractor ShowEmail Address Extractor allows to extract automatically all the e-mail addresses from Outlook Express or other application. Then, you can import the results into your Windows address book, Excel, Word or other application. The extracted e-mail...
Download Iconix eMail ID ShowIf you are fed up with receiving all kinds of spams, then try at once Iconix. Iconix eMail ID is a program which verifies the authenticity of your e-mail as soon as it arrives. - To begin, it checks. - Then if the e-mail is authentic, it marks...
Structure of an email (Headers and bodies) ShowStructure of an email An email has three basic parts: The header, a set of lines containing information about the message's transportation, such as the sender's address, the recipient's address, or timestamps showing when the message was sent by...
Base64 encoding ShowBase64 encoding The concept of Base64 encoding entails using US-ASCII (non-accented) characters to encode any sort of data in 8-bit form. Email protocols were originally designed to send messages in plain text only. But as email systems vary...