File: EmailValidator.php

Recommend this page to a friend!
  Classes of Archzilon Eshun-Davies   Secure JS   EmailValidator.php   Download  
File: EmailValidator.php
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Secure JS
Validate text values to detect unsafe characters
Author: By
Last change: Update of EmailValidator.php
Date: 2 years ago
Size: 868 bytes
 

Contents

Class file image Download
<?php /** * EmailValidator: A more logical email validator. * * @copyright Copyright (c) 2018, Archzilon Eshun-Davies <laudarch@qremiaevolution.org> * @license MIT, http://www.opensource.org/licenses/mit-license.php */ class EmailValidator { /** * isValidEmail: Check if email is valid * * @param $email * @return bool * Usage: * $ret = EmailValidator::isValidEmail("name@host.sk"); * if ($ret) * echo "VALID EMAIL"; * else * echo "INVALID EMAIL"; */ public static function isValidEmail($email) { $email_apart = preg_split('/@/', $email); if (count($email_apart) <= 1) return false; $username = $email_apart[0]; $hostname = $email_apart[1]; $mxhosts = array(); $dns = checkdnsrr($hostname); $mx = getmxrr($hostname, $mxhosts); return ($dns && $mx && count($mxhosts) >= 1) ? true : false; } } ?>