Do all email providers ignore periods in front of @?

后端 未结 3 1398
别那么骄傲
别那么骄傲 2020-12-29 01:41

I know that gmail lets a user insert as many periods as he/she wants in an email address before the @ sign. Gmail also lets users append the email address like this: userNam

3条回答
  •  孤城傲影
    2020-12-29 02:39

    Over the last few days, I encountered the same problem. After researching on the web and checking a few things, I found that:

    • DOTS MATTER IN: Microsoft Outlook, Yahoo Mail, Apple iCloud ID
    • DOTS DON’T MATTER IN: Gmail, Facebook ID
    • DOTS STRICTLY PROHIBITED: Twitter

    Source: An article on Slate

    I came to the conclusion that a majority of users use services offered by Microsoft, Google, or Yahoo. So I can have an application-specific regex like this.

    var eml_exp = /^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@(gmail.com)$/i;
    if(eml_exp.test("email@addrss"))
    //if it's a gmail address, then remove periods from local part and also anything
    // after `+` sign . Then compare the address in your existing user table,
    // if you find it unique or unused then let the user to register.
    

    You can read manuals of other known services also and implement according to them.

    "Don't forget to open source your work :p"

    Update

    According to this SO question Adding + text before the @ in an email , you may block use of + sign the whole problem of yours and mine will get solved.

提交回复
热议问题