/isemail

[WIP] Creating an email validator from the original http://www.dominicsayers.com/isemail/ to a more OOP aproach. See https://github.com/symfony/symfony/issues/1581

Primary LanguagePHP

EmailValidator (old is_email)

Work will continue here EmailValidator

Build Status

How to use ?

Install via composer.

Simple example:

<?php

use IsEmail\EmailValidator;

$validator = new EmailValidator;
if ($validator->isValid($email)) {
	echo $email . ' is a valid email address';
}

More advanced example (returns detailed diagnostic error codes):

<?php

require_once 'EmailValidator.php';

$validator = new EmailValidator;
$email = 'dominic@sayers.cc';
$result = $validator->isValid($email);

if ($result) {
	echo $email . ' is a valid email address';
} else if ($validator->hasWarnings()) {
	echo 'Warning! ' . $email . ' has unusual/deprecated features (result code ' . var_export($validator->getWarnings(), true) . ')';
} else {
	echo $email . ' is not a valid email address (result code ' . $validator->getError() . ')';
}

Copyright

Copyright (c) 2008-2011 Dominic Sayers dominic@sayers.cc

Contributors

License

BSD License (http://www.opensource.org/licenses/bsd-license.php)