Skip to content

Normalization of email for bans, for request cache to SFS or for checking the uniqueness of new users.

License

Notifications You must be signed in to change notification settings

MioVisman/NormEmail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Normalization of email for bans, for request cache to SFS or for checking the uniqueness of new users.

Topics

Resources

License

Stars

Watchers

Forks

Languages