Skip to main content

Simple function to validate an email address.

/**
 * Validate an email address.
 *
 * @param string $email
 * @return bool Returns true if valid email address, otherwise false.
 */  
function validate_email($email) {
  return (!preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $email)) ? false : true;
}