A simple email value object for your projects

v1.2 2016-10-07 15:57 UTC


PHP 5.4+ library to make working with Email safer, easier, and fun!

SensioLabsInsight Build Status Scrutinizer Quality Score Latest Stable Version Total Downloads


The recommended way to install Email is through Composer:

    "require": {
        "black/email": "@stable"

Protip: You should browse the black/email page to choose a stable version to use, avoid the @stable meta constraint.


Usage is simple. Just create a new EmailEmail, if your email is invalid an Email\Exception\InvalidEmailEmailException will be thrown. Be aware of this, the validation is on the format, not on a A or MX record in a valid DNS.

$email = new Email\EmailEmail("");
$email->getValue(); // return
$email->getValueAsArray() // return ['recipient' => "foo", 'domain' => "bar", 'tld' => "com"]

List of available getters

  • getValue()
  • getValueAsArray()
  • getRecipient()
  • getDomain()
  • getTld()

Check if two email are equals

isEqualTo(Email\EmailEmail $email): Check if two emails are equals


FILTER_VALIDATE_EMAIL will not works with non-standard ASCII characters so an email like this will throw an InvalidEmailAddressException.

FILTER_VALIDATE_EMAIL don't know rules of providers. is invalid for hotmail but valid for PHP.


Email is released under the MIT License. See the bundled LICENSE file for details.




This README is heavily inspired by Geocoder library by the great @willdurand. This guy needs your PR for the sake of the REST in PHP.

Alexandre "pocky" Balmes Send me Flattrs if you love my work, buy me gift or hire me!