Email
PHP 5.4+ library to make working with Email safer, easier, and fun!, (*1)
, (*2)
Installation
The recommended way to install Email is through Composer:, (*3)
{
"require": {
"black/email": "@stable"
}
}
Protip: You should browse the black/email
page to choose a stable version to use, avoid the @stable
meta
constraint., (*4)
Usage
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., (*5)
$email = new Email\EmailEmail("foo@bar.com");
$email->getValue(); // return foot@bar.com
$email->getValueAsArray() // return ['recipient' => "foo", 'domain' => "bar", 'tld' => "com"]
List of available getters, (*6)
getValue()
getValueAsArray()
getRecipient()
getDomain()
getTld()
Check if two email are equals, (*7)
isEqualTo(Email\EmailEmail $email)
: Check if two emails are equals, (*8)
WARNING, (*9)
FILTER_VALIDATE_EMAIL
will not works with non-standard ASCII characters so an email like this
me@domain.中国
will throw an InvalidEmailAddressException., (*10)
FILTER_VALIDATE_EMAIL
don't know rules of providers. 0me@hotmail.com
is invalid for hotmail but valid for PHP., (*11)
License
Email is released under the MIT License. See the bundled LICENSE file for details., (*12)
Contributing
See CONTRIBUTING file., (*13)
Credits
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., (*14)
Alexandre "pocky" Balmes alexandre@lablackroom.com. Send me Flattrs if you love my work, [buy me gift][9] or hire me!, (*15)