Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Email Laravel Package

black/email

PHP 5.4+ value object for safer email handling. Validates email format (throws on invalid), exposes recipient/domain/tld getters, array parsing, and equality checks. Note: relies on FILTER_VALIDATE_EMAIL; limited for non-ASCII and provider rules.

View on GitHub
Deep Wiki
Context7

Email

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

SensioLabsInsight Build Status Scrutinizer Quality Score Latest Stable Version Total Downloads

Installation

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

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("foo@bar.com");
$email->getValue(); // return foot@bar.com
$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

WARNING

FILTER_VALIDATE_EMAIL will not works with non-standard ASCII characters so an email like this me@domain.中国 will throw an InvalidEmailAddressException.

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

License

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

Contributing

See CONTRIBUTING file.

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.

Alexandre "pocky" Balmes alexandre@lablackroom.com. Send me Flattrs if you love my work, buy me gift or hire me!

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky