public static function validateEmail($address, $tempEmailAllowed = true)
    {
        strpos($address, '@') ? list(, $mailDomain) = explode('@', $address) : $mailDomain = null;
        if (filter_var($address, FILTER_VALIDATE_EMAIL) &&
            !is_null($mailDomain) &&
            checkdnsrr($mailDomain, 'MX')
        ) {
            if ($tempEmailAllowed) {
                return true;
            } else {
                $handle = fopen(__DIR__.'/banned.txt', 'r');
                $temp = [];
                while (($line = fgets($handle)) !== false) {
                    $temp[] = trim($line);
                }
                if (in_array($mailDomain, $temp)) {
                    return false;
                }

                return true;
            }
        }

        return false;
    }
public static function validateEmail($address, $tempEmailAllowed = true)
    {
        strpos($address, '@') ? list(, $mailDomain) = explode('@', $address) : $mailDomain = null;
        if (filter_var($address, FILTER_VALIDATE_EMAIL) &&
            !is_null($mailDomain) &&
            checkdnsrr($mailDomain, 'MX')
        ) {
            if ($tempEmailAllowed) {
                return true;
            } else {
                $handle = fopen(__DIR__.'/banned.txt', 'r');
                $temp = [];
                while (($line = fgets($handle)) !== false) {
                    $temp[] = trim($line);
                }
                if (in_array($mailDomain, $temp)) {
                    return false;
                }

                return true;
            }
        }

        return false;
    }
public static function validateEmail ( $ address , $ tempEmailAllowed = true ) { strpos ( $ address , '@' ) ? list ( , $ mailDomain ) = explode ( '@' , $ address ) : $ mailDomain = null ; if ( filter_var ( $ address , FILTER_VALIDATE_EMAIL ) && ! is_null ( $ mailDomain ) && checkdnsrr ( $ mailDomain , 'MX' ) ) { if ( $ tempEmailAllowed ) { return true ; } else { $ handle = fopen ( __DIR__ . '/banned.txt' , 'r' ) ; $ temp = [ ] ; while ( ( $ line = fgets ( $ handle ) ) !== false ) { $ temp [ ] = trim ( $ line ) ; } if ( in_array ( $ mailDomain , $ temp ) ) { return false ; } return true ; } } return false ; }
Validate Email address.

@param string $address          Email address to validate
@param bool   $tempEmailAllowed Allow Temporary email addresses?

@return bool True if email address is valid, false is returned otherwise
Validate Email address .