This repo is a golang port of JS library: https://github.com/iDoRecall/email-normalize
normalize-email normalizes email addresses to their canonical form.
- remove dots in GMail or email addresses hosted by similar services (Google Apps for Work, FastMail)
- remove address tags starting with '+', or '-' for Yahoo!, or '=' as well if desired
- converts alias domains to the canonical one, e.g. googlemail.com to gmail
gmail.com
,googlemail.com
andgoogle.com
- the only domains Google is known to use for incoming email- Any domain hosted with Google Apps for Work
- FastMail and domains hosted with FastMail
- Microsoft's outlook.com, hotmail.com, live.com
- Yahoo! domains
// Gmail dots
"a.b.c@gmail.com": "abc@gmail.com",
"a.b.c@yahoo.com": "a.b.c@yahoo.com",
// Google domains
"a.b.c@googlemail.com": "abc@gmail.com",
// Plus
"a.b.c+tag@gmail.com": "abc@gmail.com",
"a.b.c+tag@yahoo.com": "a.b.c+tag@yahoo.com",
// Non-standard TLDs
"a.b.c+tag@something.co.uk": "a.b.c+tag@something.co.uk",
// Yahoo!
"a.b.c.d+tag@yahoo.com": "a.b.c.d+tag@yahoo.com",
"a.b.c-tag@yahoo.com": "a.b.c@yahoo.com",
"a.b.c-tag@yahoo.co.uk": "a.b.c@yahoo.co.uk",
"a-b.c-tag@yahoo.ro": "a@yahoo.ro",
// Microsoft
"a.b.c+tag@outlook.com": "a.b.c@outlook.com",
"a.b.c-tag@hotmail.com": "a.b.c-tag@hotmail.com",
"a.b.c-tag@outlook.co.uk": "a.b.c-tag@outlook.co.uk",
"a.b.c+d@live.com": "a.b.c@live.com",
// Google Apps for Work
"a.b.c+tag@idorecall.com": "a.b.c+tag@idorecall.com",
sync version
...
rawEmail := "john123.thomas123+test123@googlemail.com
normEmail := normalize_email.Normalize(rawEmail, nil, nil)
// normEmail == "john123.thomas@gmail.com"
...
async version for detect provider
...
callback = make(chan string)
...
rawEmail := "john123.thomas123+test123@googlemail.com
_ := normalize_email.Normalize(rawEmail, &Option{DetectProvider: true}, callback)
...
normEmail := <- callback
// normEmail == "john123.thomas@gmail.com"
...
Please also refer normalize_test.go for examples.
_