Email address value object.

v2.2.0 2019-12-23 11:43 UTC

This package is auto-updated.

Last update: 2020-03-28 17:50:17 UTC


Build Status Coverage Status Downloads this Month Latest stable


Via Composer:

$ composer require nepada/email-address


Creating value object

$emailAddress = Nepada\EmailAddress\EmailAddress::fromString('Real.example+suffix@HÁČKYčá');
$emailAddress = Nepada\EmailAddress\EmailAddress::fromDomainAndLocalPart('HÁČKYčá', 'Real.example+suffix');

Nepada\EmailAddress\InvalidEmailAddressException is thrown in case of invalid input value.

Converting back to string

echo((string) $emailAddress); // Real.example+suffix@HÁČKYčá
echo($emailAddress->toString()); // Real.example+suffix@HÁČKYčá
echo($emailAddress->getOriginalValue()); // Real.example+suffix@HÁČKYčá

Email address with normalized domain part

echo($emailAddress->getValue()); //

Whole email address normalized and lowercased

echo($emailAddress->getLowercaseValue()); //

Note: This is not RFC 5321 compliant, however in practice all major mail providers treat local part in case insensitive manner.

Getting local and domain part separately

echo($emailAddress->getLocalPart()); // Real.example+suffix
echo($emailAddress->getDomain()); //