Validate email

@param $email
@return mixed

@deprecated See JBZoo\Utils\Email
354682
public static function email($email)
    {
        $email = Str::trim($email);
        $cleaned = filter_var($email, FILTER_VALIDATE_EMAIL);

        if (Email::isValid($cleaned)) {
            return $cleaned;
        }

        return false;
    }
1238709
public function validateEmail($email)
    {
        if (empty($email)) {
            $this->addError('email', 'Email cannot be empty');
            return false;
        }

        if (mb_strlen($email, 'UTF-8') > 255) {
            $this->addError('email', 'Email length has to be less or equal to 255');
            return false;
        }

        $emailValidator = new EmailValidator();
        if (!$emailValidator->isValid($email, new RFCValidation())) {
            $this->addError('email', 'Email must be an email address');
            return false;
        }

        return true;
    }
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;
    }
405487
public function email($email = null) {
		$this->out('Email:');
		while (empty($email) || !Validation::email($email)) {
			$email = $this->in('New email address (must have a valid form at least)');
		}

		/** @var \App\Model\Table\UsersTable $Users */
		$Users = TableRegistry::get(CLASS_USERS);
		$this->Users = $Users;
		if (!$this->Users->hasField('email')) {
			$this->abort(CLASS_USERS . ' table doesnt have an email field!');
		}

		$this->hr();
		$this->out('Resetting...');

		if (empty($this->params['dry-run'])) {
			$count = $this->Users->updateAll(['email' => $email . ''], ['email !=' => $email]);
		} else {
			$count = $this->Users->find('all', ['conditions' => [CLASS_USERS . '.email !=' => $email]])->count();
		}
		$this->out($count . ' emails resetted - DONE');
	}
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);
    }
465745
public function validateEmail($email)
    {
        // Split email address up and disallow '..'
        $pattern = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i";
        if ((strpos($email, '..') === false) && preg_match( $pattern, $email))
        {
            return true;
        }

        return false;
    }
144911
public function withVerifiedEmail($email)
    {
        $request = clone $this;
        $request->email = $email instanceof Email ? $email : new Email($email);
        $request->emailIsVerified = true;

        return $request;
    }
792514
public function verifyEmail($email)
    {
        $path = 'users/verify_email';
        $request =  $this->_remoteServer->get($path);
        $request->getQuery()->set('email', $email);
        $response = $request->send();
        return $response->getBody('true');
    }
101196
public function isEmailBanned($email)
    {
        $emailTemplates = $this->getEmailTemplates();

        foreach ($emailTemplates as $emailTemplate) {
            $emailRule = new Email($emailTemplate);
            if ($emailRule->check($email)) {
                return true;
            }
        }
        return false;
    }
1356635
public function normalizeEmail($email)
    {
        if (preg_match('#[^(\x20-\x7F)]+#', $email)) {

            list($user, $domain) = explode('@', $email);

            return $user . '@' . $this->punycode($domain);

        } else {
            return $email;
        }
    }
1072760
public function email($key) {
        $v = new EmailValidator($this->shell->_unsafeVar[$key] ?? null, $this->shell);
        $v->_isUndefined = !array_key_exists($key, $this->shell->_unsafeVar);
        $this->shell->subValidators[$key] = $v;
        return $v;
    }
404854
protected function normalizeEmail($email)
    {
        if (is_array($email)) {

            $emails = [];

            foreach ($email as $k => $v) {
                if (is_int($k)) {
                    $emails[$k] = $this->getManager()->normalizeEmail($v);
                } else {
                    $k = $this->getManager()->normalizeEmail($k);
                    $emails[$k] = $v;
                }
            }

            return $emails;

        } else {
            return $this->getManager()->normalizeEmail($email);
        }
    }
289876
public function sendEmail($email)
    {
        return send_mail(
            'no-reply',
            get_app_name(),
            $email, $this->subject,
            $this->body,
            'html',
            '/contact/html',
            [
                'title' => 'This is title',
                'contact_name' => $this->name,
                'contact_email' => $this->email,
            ]
        );
    }
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)
1036120
public static function oneByEmail($email)
	{
		if (!filter_var($email, FILTER_VALIDATE_EMAIL))
		{
			return self::oneByUsername($email);
		}

		return self::all()
			->whereEquals('email', $email)
			->row();
	}
1282419
protected function passwordReset($email)
    {
        if (empty($email)) {
            throw new BadRequestException("Missing required email for password reset confirmation.");
        }

        /** @var User $user */
        $user = User::whereEmail($email)->first();

        if (null === $user) {
            // bad code
            throw new NotFoundException("The supplied email was not found in the system.");
        }

        static::isAllowed($user);

        // if security question and answer provisioned, start with that
        $question = $user->security_question;
        if (!empty($question)) {
            return ['security_question' => $question];
        }

        // otherwise, is email confirmation required?
        $user->confirm_code = Registrar::generateConfirmationCode(\Config::get('df.confirm_code_length', 32));
        $user->save();

        $sent = $this->sendPasswordResetEmail($user);

        if (true === $sent) {
            return ['success' => true];
        } else {
            throw new InternalServerErrorException(
                'No security question found or email confirmation available for this user. Please contact your administrator.'
            );
        }
    }
1227068
function validate($email, $checkDomain = false)
    {
        if (preg_match($this->regex, $email)) {
            if ($checkDomain && function_exists('checkdnsrr')) {
                $tokens = explode('@', $email);
                if (checkdnsrr($tokens[1], 'MX') || checkdnsrr($tokens[1], 'A')) {
                    return true;
                }
                return false;
            }
            return true;
        }
        return false;
    }