Validates a username.

@param string $email Email to validate     *

@return bool
776285
public function validateUsername($username)
    {
        $person = $this->getService('repos:people.person')->find(array('username' => $username));

        if ($person) {
            $this->setMessage('Username is already in use');
            return false;
        }

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

        return false;
    }
100878
public static function isValidEmail($email)
    {
        /*
         * Not a string?
         * Nothing to do
         */
        if (!is_string($email)) {
            return false;
        }

        $pattern = self::getEmailPattern();

        return (bool)preg_match($pattern, $email);
    }
1111998
protected static function validateEmailAddress($email) {
		if (empty($email)) {
			throw new InvalidEmailException();
		}

		$email = \trim($email);

		if (!\filter_var($email, \FILTER_VALIDATE_EMAIL)) {
			throw new InvalidEmailException();
		}

		return $email;
	}
898772
public static function isEmail($email)
    {
        $pattern = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i";
        if (is_string($email) && preg_match($pattern, $email)) {
            return true;
        }

        return false;
    }
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;
    }
607295
public function setEmail($email)
    {
        $validator = new EmailValidator();
        if ($validator->validate($email)) {
            $this->_email = $email;
        } else {
            $this->_email = false;
        }
    }
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' ) );
        }
42842
private function userFromEmail($email)
    {
        $parts = explode('@', $email);

        if (count($parts) == 2) {
            return strtolower($parts[0]);
        }

        return null;
    }
212182
public function isSendable($email)
    {
        // Does it look like an email address?
        if (! $this->isEmail($email)) {
            return false;
        }

        // Is is an example domain?
        if ($this->isExample($email)) {
            return false;
        }

        // Does it have an MX record?
        if (! $this->hasMx($email)) {
            return false;
        }

        return true;
    }
538851
public function findUserByUsernameOrEmail($username, $email)
    {
        $dql = '
            SELECT u
            FROM Claroline\CoreBundle\Entity\User u
            WHERE u.username = :username
            OR u.email = :email
            AND u.isRemoved = false
        ';

        $query = $this->_em->createQuery($dql);
        $query->setParameter('username', $username);
        $query->setParameter('email', $email);

        return $query->getResult();
    }
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);
    }
852036
public function exists($email)
    {
        $url = $this->gravatar->buildGravatarURL($email);
        $headers = get_headers($url, 1);
	    
        return (boolean) strpos($headers[0], '200');
    }
316246
public static function addressValidate($email)
    {
        // $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
        $return = false;
        $regex = '/^'
            .'[a-z0-9_]+([_\.-][a-z0-9]+)*'     // user
            .'@'
            .'([a-z0-9]+([\.-][a-z0-9]+)*)+'    // domain
            .'(\.[a-z]{2,})'                    // sld, tld
            .'$/i';
        $email = trim($email);
        if (preg_match($regex, $email, $matches)) {
            // $this->debug->log('properly formatted');
            $hostname   = strtolower($matches[2].$matches[4]);
            $ipaddress  = gethostbyname($hostname);     // A record
            // $this->debug->log('hostname', $hostname);
            // $this->debug->log('ipaddress', $ipaddress);
            $return = $email;
            if ($ipaddress != $hostname) {
                // $this->debug->log('A record', $ipaddress);
            } elseif ($mxrecord = getmxrr($hostname, $mxhosts)) {
                // $this->debug->log('getmxrr('.$hostname.')', $mxrecord, $mxhosts);
            } elseif (strpos($_SERVER['SERVER_NAME'], $hostname)) {
                // $this->debug->log('email domain matches server domain');
            } else {
                // $this->debug->log('warn', 'unable to verify');
                $return = false;
            }
        }
        // $this->debug->groupEnd();
        return $return;
    }
695716
public function setEmail($email)
    {
        $email = trim($email);

        if (preg_match('/\<(.*)\>/', $email, $matches)) {
            $email = trim(str_replace($matches[ 0 ], '', $email));
            $name = $matches[ 1 ];
        }

        if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
            $this->email = $email;

            if (isset($name)) {
                $this->setName($name);
            }
        }

        return $this;
    }
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');
    }
1184821
public function validateEmailSender($email)
    {
        if (mb_strlen($email, 'UTF-8') > 255) {
            $this->addError(EmailConfigurationTransformer::EMAIL_SENDER, 'Sender email length has to be less or equal to 255');
            return false;
        }

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

        return true;
    }