Check if the email is valid.

@param string $email
@param bool   $useExampleDomainCheck
@param bool   $useTypoInDomainCheck
@param bool   $useTemporaryDomainCheck
@param bool   $useDnsCheck             (do not use, if you don't need it)

@return bool
177650
public static function isValid(string $email, bool $useExampleDomainCheck = false, bool $useTypoInDomainCheck = false, bool $useTemporaryDomainCheck = false, bool $useDnsCheck = false): bool
    {
        if (!isset($email[0])) {
            return false;
        }

        // make sure string length is limited to avoid DOS attacks
        $emailStringLength = \strlen($email);
        if (
            $emailStringLength >= 320
            ||
            $emailStringLength <= 2 // i@y //
        ) {
            return false;
        }
        unset($emailStringLength);

        $email = \str_replace(
            [
                '.', // non-Latin chars are also allowed | https://tools.ietf.org/html/rfc6530
                '＠', // non-Latin chars are also allowed | https://tools.ietf.org/html/rfc6530
            ],
            [
                '.',
                '@',
            ],
            $email
        );

        if (
            (\strpos($email, '@') === false) // "at" is needed
            ||
            (\strpos($email, '.') === false && \strpos($email, ':') === false) // "dot" or "colon" is needed
        ) {
            return false;
        }

        if (!\preg_match('/^(?<local>.*<?)(?:.*)@(?<domain>.*)(?:>?)$/', $email, $parts)) {
            return false;
        }

        $local = $parts['local'];
        $domain = $parts['domain'];

        if (!$local) {
            return false;
        }

        if (!$domain) {
            return false;
        }

        // Escaped spaces are allowed in the "local"-part.
        $local = \str_replace('\\ ', '', $local);

        // Spaces in quotes e.g. "firstname lastname"@foo.bar are also allowed in the "local"-part.
        $quoteHelperForIdn = false;
        if (\preg_match('/^"(?<inner>[^"]*)"$/mU', $local, $parts)) {
            $quoteHelperForIdn = true;
            $local = \trim(
                \str_replace(
                    $parts['inner'],
                    \str_replace(' ', '', $parts['inner']),
                    $local
                ),
                '"'
            );
        }

        if (
            \strpos($local, ' ') !== false // no spaces allowed, anymore
            ||
            \strpos($local, '".') !== false // no quote + dot allowed
        ) {
            return false;
        }

        list($local, $domain) = self::punnycode($local, $domain);

        if ($quoteHelperForIdn === true) {
            $local = '"' . $local . '"';
        }

        $email = $local . '@' . $domain;

        if (!\filter_var($email, \FILTER_VALIDATE_EMAIL)) {
            return false;
        }

        if ($useExampleDomainCheck === true && self::isExampleDomain($domain) === true) {
            return false;
        }

        if ($useTypoInDomainCheck === true && self::isTypoInDomain($domain) === true) {
            return false;
        }

        if ($useTemporaryDomainCheck === true && self::isTemporaryDomain($domain) === true) {
            return false;
        }

        if ($useDnsCheck === true && self::isDnsError($domain) === true) {
            return false;
        }

        return true;
    }
941748
private function validateEmail($email)
    {
        if (!$this->cartHelper->validateEmail($email)) {
            throw new BoltException(
                __('Invalid email: %1', $email),
                null,
                BoltErrorResponse::ERR_UNIQUE_EMAIL_REQUIRED
            );
        }
    }
539349
public function isEmail($checkDNS = true)
    {
        $isValid = filter_var($this->returnValue, FILTER_VALIDATE_EMAIL) !== false;
        if ($isValid && $checkDNS) {
            $domain  = substr(strrchr($this->returnValue, "@"), 1);
            // domain not found in DNS
            $isValid = checkdnsrr($domain, "MX") && checkdnsrr($domain, "A");
        }
        return $isValid;
    }
1254747
public static function isExistByEmail( $email ) {

		$user = self::find()->where( 'email=:email', [ ':email' => $email ] )->one();

		return isset( $user );
	}
596895
public function validateEmail($email)
    {
        if (empty($email)) {
            return false;
        }

        $validationViolationList = $this
            ->validator
            ->validate($email, new Email());

        return $validationViolationList->count() === 0;
    }
1370332
private function isConfiguredDomain($email)
    {
        foreach ($this->hostedDomains as $hostedDomain) {
            if (preg_match('/'.$hostedDomain['domain_name'].'$/', $email)) {
                return true;
            }
        }

        return false;
    }
55597
def valid_email(emailaddress, domains=GENERIC_DOMAINS):
    """"""

    # Email address must be at least 6 characters in total.
    # Assuming noone may have addresses of the type a@com
    if len(emailaddress) < 6:
        return False  # Address too short.

    # Split up email address into parts.
    try:
        localpart, domainname = emailaddress.rsplit('@', 1)
        host, toplevel = domainname.rsplit('.', 1)
    except ValueError:
        return False  # Address does not have enough parts.

    # Check for Country code or Generic Domain.
    if len(toplevel) != 2 and toplevel not in domains:
        return False  # Not a domain name.

    for i in '-_.%+.':
        localpart = localpart.replace(i, "")
    for i in '-_.':
        host = host.replace(i, "")

    if localpart.isalnum() and host.isalnum():
        return True  # Email address is fine.
    else:
        return False
529776
public function isValid($email)
    {
        if (false === $email = filter_var($email, FILTER_VALIDATE_EMAIL)) {
            return false;
        }

        try {
            list($local, $domain) = Utilities::parseEmailAddress($email);
        } catch (InvalidEmailException $e) {
            return false;
        }

        return !$this->adapter->isThrowawayDomain($domain);
    }
1240168
private function isEmailValid($email)
    {
        $constraints = array(
            new \Symfony\Component\Validator\Constraints\Email(),
            new \Symfony\Component\Validator\Constraints\NotBlank()
        );

        $errors = $this->validator->validate($email, $constraints);
        return count($errors) === 0;
    }
628537
public function hasMx($email)
    {
        if (! $this->isEmail($email)) {
            return null;
        }

        $hostname = $this->hostnameFromEmail($email);

        if ($hostname) {
            return checkdnsrr($hostname, 'MX');
        }

        return null;
    }
1220824
private function checkHeadersForInjection(\sb\Email $email)
    {

        if (\preg_match("~\r|:~i", $email->to) || preg_match("~\r|:~i", $email->from)) {
            return true;
        }

        return false;
    }
933041
public function isEmailVerified($email) {
        try {
            $user = $this->api('/user/'.$email);
            if (isset($user['emails']) && is_array($user['emails']) && count($user['emails']) > 0) {
                foreach ($user['emails'] as $key => $value) {
                    if (isset($value['verified']) && $value['verified'] == true && $value['value'] == $email) {
                        return true;
                    }
                }
            }
        } catch (VGS_Client_Exception $e) {
            self::errorLog('Exception thrown when getting logged in user:'. $e->getMessage());
        }
        return false;
    }
1188670
protected function validateEmail($sEmail)
    {
        if (empty($sEmail)) {
            throw new ValidationException('No email address supplied');
        } elseif (is_string($sEmail) && !valid_email($sEmail)) {
            throw new ValidationException('"' . $sEmail . '" is not a valid email');
        }
    }
377645
protected function validateEmail($email) {
        $state['error'] = true;

        if (strlen($email) < (int)$this->config->verify_email_min_length ) {
            $state['message'] = $this->__lang("email_short", (int)$this->config->verify_email_min_length);

            return $state;
        } elseif (strlen($email) > (int)$this->config->verify_email_max_length ) {
            $state['message'] = $this->__lang("email_long", (int)$this->config->verify_email_max_length);

            return $state;
        } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            $state['message'] = $this->__lang("email_invalid", $email);

            return $state;
        }
        
        if ((int)$this->config->verify_email_use_banlist && $this->isEmailBanned($email)) {
            $this->addAttempt();
            $state['message'] = $this->__lang("email_banned");

            return $state;
        }

        $state['error'] = false;

        return $state;
    }
1000423
protected function _validateEmail($email, $context)
    {
        if ($this->_emailPattern === null) {
            if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
                return;
            }
        } elseif (preg_match($this->_emailPattern, $email)) {
            return;
        }

        $context = ltrim($context, '_');
        if ($email == '') {
            throw new InvalidArgumentException(sprintf('The email set for "%s" is empty.', $context));
        }
        throw new InvalidArgumentException(sprintf('Invalid email set for "%s". You passed "%s".', $context, $email));
    }
277045
public static function CheckEmail($email){
		   if(preg_match("/^[\-\!\#\$\%\&\'\*\+\.\/0-9\=\?A-Z\^\_\`a-z\{\|\}\~]+\@([\-\!\#\$\%\&\'\*\+\/0-9\=\?A-Z\^\_\`a-z\{\|\}\~]+\.)+[a-zA-Z]{2,6}$/", $email)){
		   	  $var=explode("@",$email);
		   	  $var=array_pop($var);
		      if(checkdnsrr($var,"MX")){return true;}else{return false;}
		   }else{
		      return false;
		   }
		}
32716
private static function checkValidate(Meta $m)
    {
        if (!empty($m->getAllow()['validate'])) {
            if ($m->getAllow()['validate'] === "email" && !Check::email($m->getValue())) {
                if ($m->getDefault() === false)
                    $m->setError("email inválido.");
                else
                    $m->setValue($m->getDefault(), !1);

            } elseif ($m->getAllow()['validate'] === "cpf" && !Check::cpf($m->getValue())) {
                if ($m->getDefault() === false)
                    $m->setError("CPF inválido.");
                else
                    $m->setValue($m->getDefault(), !1);

            } elseif ($m->getAllow()['validate'] === "cnpj" && !Check::cnpj($m->getValue())) {
                if ($m->getDefault() === false)
                    $m->setError("CNPJ inválido.");
                else
                    $m->setValue($m->getDefault(), !1);
            }
        }
    }