Internal method to validate the local part of the email address

@return boolean
472
private function _validateLocalPart()
    {
        // First try to match the local part on the common dot-atom format
        $result = false;

        // Dot-atom characters are: 1*atext *("." 1*atext)
        // atext: ALPHA / DIGIT / and "!", "#", "$", "%", "&", "'", "*",
        //        "+", "-", "/", "=", "?", "^", "_", "`", "{", "|", "}", "~"
        $atext = 'a-zA-Z0-9\x21\x23\x24\x25\x26\x27\x2a\x2b\x2d\x2f\x3d\x3f\x5e\x5f\x60\x7b\x7c\x7d\x7e';
        if (preg_match('/^[' . $atext . ']+(\x2e+[' . $atext . ']+)*$/', $this->_localPart)) {
            $result = true;
        } else {
            // Try quoted string format

            // Quoted-string characters are: DQUOTE *([FWS] qtext/quoted-pair) [FWS] DQUOTE
            // qtext: Non white space controls, and the rest of the US-ASCII characters not
            //   including "\" or the quote character
            $noWsCtl = '\x01-\x08\x0b\x0c\x0e-\x1f\x7f';
            $qtext   = $noWsCtl . '\x21\x23-\x5b\x5d-\x7e';
            $ws      = '\x20\x09';
            if (preg_match('/^\x22([' . $ws . $qtext . '])*[$ws]?\x22$/', $this->_localPart)) {
                $result = true;
            } else {
                $this->_error(self::DOT_ATOM);
                $this->_error(self::QUOTED_STRING);
                $this->_error(self::INVALID_LOCAL_PART);
            }
        }

        return $result;
    }
201723
protected function validateCityAddress()
    {
        $field = 'city_id';

        if ($this->isExcluded($field) || $this->isError('country')) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        $label = $this->translation->text('City');
        $format = $this->getCountryFormatAddress();

        if (empty($value) && !empty($format['city_id']['required'])) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        // City ID can be either numeric ID or non-numeric human name
        if (is_numeric($value)) {
            if ($this->city->get($value)) {
                return true;
            }
            $this->setErrorUnavailable($field, $label);
            return false;
        }

        if (empty($value)) {
            return true;
        }

        if (mb_strlen($value) > 255) {
            $this->setErrorLengthRange($field, $label);
            return false;
        }

        // Try to convert human name to a numeric ID
        $country = $this->getSubmitted('country');
        $state_id = $this->getSubmitted('state_id');

        if (empty($country) || empty($state_id)) {
            return true;
        }

        $conditions = array(
            'name' => $value,
            'country' => $country,
            'state_id' => $state_id
        );

        foreach ((array) $this->city->getList($conditions) as $city) {
            if (strcasecmp($city['name'], $value) === 0) {
                $this->setSubmitted($field, $city['city_id']);
                break;
            }
        }

        return true;
    }
1050897
public function getEmailMultiLanguage()
    {
        if ($this->offsetExists('email') && isset($this->email['multiLanguage'])) {
            return (boolean) $this->email['multiLanguage'];
        } else {
            return true;
        }
    }
109941
public static boolean isEmail(final String string) {
        if (StringUtils.isBlank(string)) {
            return false;
        }

        if (MAX_EMAIL_LENGTH < string.length()) {
            return false;
        }

        final String[] parts = string.split("@");

        if (2 != parts.length) {
            return false;
        }

        final String local = parts[0];

        if (MAX_EMAIL_LENGTH_LOCAL < local.length()) {
            return false;
        }

        final String domain = parts[1];

        if (MAX_EMAIL_LENGTH_DOMAIN < domain.length()) {
            return false;
        }

        return EMAIL_PATTERN.matcher(string).matches();
    }
162782
public function isValid()
    {
        // these schemes are allowed
        $allowedSchemes = $this->getAllowedSchemes();

        // get the field value
        $url = $this->field->getValue();


        // not required and empty? Then its valid
        if ($this->isNotRequiredAndEmpty($url)) {
            return true;
        }

        if ($this->getMaxLength() && strlen($url) > $this->getMaxLength()) {
            // Over maximum length.
            return false;
        }

        // do simple validation
        if (!filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED | FILTER_FLAG_SCHEME_REQUIRED)) {
            return false;
        }

        // check if we have a tld
        if (!$this->isSkipTldCheck() && !preg_match('#\.[a-z]{2,}$#', parse_url($url, PHP_URL_HOST))) {
            return false;
        }

        // further validation is required.
        if (in_array(parse_url($url, PHP_URL_SCHEME), $allowedSchemes)) {
            return true;
        }

        return false;
    }
1198614
public function _validation_valid_emails($val, $separator = ',')
	{
		if ($this->_empty($val))
		{
			return true;
		}

		$emails = explode($separator, $val);

		foreach ($emails as $e)
		{
			if ( ! filter_var(trim($e), FILTER_VALIDATE_EMAIL))
			{
				return false;
			}
		}
		return true;
	}
597695
protected function validateCountryCity()
    {
        $field = 'country';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        $label = $this->translation->text('Country');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        $country = $this->country->get($value);

        if (empty($country['code'])) {
            $this->setErrorUnavailable($field, $label);
            return false;
        }

        $this->setSubmitted('country', $country['code']);
        return true;
    }
203136
def validate(self, email, **kwargs):
        """"""
        email = stringify(email)
        if email is None:
            return
        if not self.EMAIL_REGEX.match(email):
            return False
        mailbox, domain = email.rsplit('@', 1)
        return self.domains.validate(domain, **kwargs)
1162448
public function validate()
    {
        if (!$this->validationHash) {
            return false;
        }
        $db = Database::connection();
        $row = $db->GetRow("select * from MailValidationHashes where mHash = ? order by mDateGenerated desc limit 1", $this->validationHash);
        if ($row['mvhID'] > 0) {
            // Can't do this even though it's a good idea
            //if ($row['email'] != $this->sender) {
            //	return false;
            //} else {
                return $row['mDateRedeemed'] == 0;
            //}
        }
    }
280623
static function is_valid_email( $email ) {
            if ( false === filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
                return false;
            }

            $parts = explode( '@', $email );

            if ( 2 !== count( $parts ) || empty( $parts[1] ) ) {
                return false;
            }

            $blacklist = array(
                'admin.',
                'webmaster.',
                'localhost.',
                'dev.',
                'development.',
                'test.',
                'stage.',
                'staging.',
            );

            // Make sure domain is not one of the blacklisted.
            foreach ( $blacklist as $invalid ) {
                if ( 0 === strpos( $parts[1], $invalid ) ) {
                    return false;
                }
            }

            // Get the UTF encoded domain name.
            $domain = idn_to_ascii( $parts[1] ) . '.';

            return ( checkdnsrr( $domain, 'MX' ) || checkdnsrr( $domain, 'A' ) );
        }
1263999
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;
    }
652324
protected function validateDataEmailStore()
    {
        $field = 'data.email';
        $value = $this->getSubmitted($field);
        $label = $this->translation->text('E-mail');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        if (!is_array($value)) {
            $this->setErrorInvalid($field, $label);
            return false;
        }

        $filtered = array_filter($value, function ($email) {
            return filter_var($email, FILTER_VALIDATE_EMAIL);
        });

        if (count($value) != count($filtered)) {
            $this->setErrorInvalid($field, $label);
            return false;
        }

        return true;
    }
1261776
public static FormValidation validateInternetAddress(String address) {
        if (Strings.isNullOrEmpty(address)) {
            return FormValidation.ok();
        }
        Matcher matcher = VALID_EMAIL_PATTERN.matcher(address);
        if (matcher.matches()) {
            return FormValidation.ok();
        } else {
            return FormValidation.error("Email address is invalid");
        }
    }
594883
public static function verify_email_address($email) {
		$email = trim($email);
		if (!$email || strlen($email) > 64)
			return false;
		return filter_var($email, FILTER_VALIDATE_EMAIL);
	}
986507
protected function ValidateStepData()
    {
        $bContinue = $this->ValidateUser($this->GetUserData());

        // which address do we need to validate? if $this->GetShipToBillingAddress() != 1 then we need to validate both..
        // otherwise one will do...

        if ('1' != $this->GetShipToBillingAddress()) {
            $bContinue = $this->ValidateShippingAddress($this->GetShippingAddressData()) && $bContinue;
            $bContinue = $this->ValidateBillingAddress($this->GetBillingAddressData()) && $bContinue;
        } else {
            switch ($this->AddressUsedAsPrimaryAddress()) {
                case TdbDataExtranetUserAddress::FORM_DATA_NAME_SHIPPING:
                    $bContinue = $this->ValidateShippingAddress($this->GetShippingAddressData()) && $bContinue;
                    break;

                default:
                case TdbDataExtranetUserAddress::FORM_DATA_NAME_BILLING:
                    $bContinue = $this->ValidateBillingAddress($this->GetBillingAddressData()) && $bContinue;
                    break;
            }
        }

        return $bContinue;
    }
3976
public function validEmail($data) {
		$data = array_shift($data);
		if (empty($data)) {
			return false;
		}

		if (is_array($data)) {
			return false;
		}

		$result = true;
		$emails = explode(CAKE_SETTINGS_APP_SMTP_EMAIL_DELIM, (string)$data);
		foreach ($emails as $email) {
			$email = trim($email);
			if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
				$result = false;
			}
		}

		return $result;
	}
1149504
protected function validateCity()
    {
        $id = $this->getUpdatingId();

        if ($id === false) {
            return null;
        }

        $data = $this->city->get($id);

        if (empty($data)) {
            $this->setErrorUnavailable('update', $this->translation->text('City'));
            return false;
        }

        $this->setUpdating($data);
        return true;
    }