Skip to content

Latest commit

 

History

History
65 lines (51 loc) · 2.29 KB

README.md

File metadata and controls

65 lines (51 loc) · 2.29 KB

NormEmail

MIT licensed

Installation

composer require miovisman/normemail

normalize() method

$nEmail = new MioVisman\NormEmail\NormEmail();

$email = $nEmail->normalize($email);
  • Method does not validate email address

  • Do not use normalized email to send emails

  • Use a normalized email to check the ban or uniqueness of the email of a new user. Check on the normalized emails ;)
  • The domain is lowercase (and in Punycode)
  • The local part is lowercase unless otherwise specified
  • The local part after the "+" is truncated (for Yahoo domains - after the "-")
// some string
                                      =>
ExampLe                               => example
ExampLe@                              => example@
exaMple.COM                           => example.com
.example.com                          => .example.com
@examPLe.com                          => example.com
"examPLe.com                          => "example.com
"[email protected]              => "[email protected]
googlemail.com                        => gmail.com
pm.me                                 => protonmail.com
yandex.tj                             => yandex.ru
ya.ru                                 => yandex.ru
.ya.ru                                => .yandex.ru

// Unicode
ПОЛЬЗОВАТЕЛЬ@домен.РУ                 => пользователь@xn--d1acufc.xn--p1ag
пользователь+тег@домен.ру             => пользователь@xn--d1acufc.xn--p1ag

// Gmail
[email protected]               => [email protected]
[email protected] => [email protected]

// Protonmail
[email protected]                 => [email protected]
[email protected]               => [email protected]

// Yahoo (.com, .ae, .at, ...)
[email protected]                => [email protected]
[email protected]                => [email protected]

// Yandex (13 domains)
user.name+tag@яндекс.рф               => [email protected]
[email protected]                  => [email protected]
[email protected]                        => [email protected]

License

This project is under MIT license. Please see the license file for details.