如何删除重复的电子邮件地址
有没有一种方法可以可靠地从用户输入的电子邮件地址中获取唯一的电子邮件地址?问题是,GMail 等服务允许您在地址中添加句点,但它会被删除,而其他服务则并非如此。
GMail:
[email protected]
[email protected]
[email protected]
所有这些都是相同的
其他服务:
[email protected]
[email protected]
这些都是独一无二的。
除了专门针对 GMail 的特殊逻辑之外,还有更好的方法吗?
Is there a way to reliably get a unique e-mail address from one put in from a user? The problem is services such as GMail allow you to put a period in the address and it's stripped out whereas with other services this is not the case.
GMail:
[email protected]
[email protected]
[email protected]
All of these are the same
Other service:
[email protected]
[email protected]
These are unique.
Other than having special logic specifically for GMail is there a better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每个电子邮件服务器对于允许和不允许的内容都有不同的规则。您指定不希望每个客户端都有特定的逻辑,因此您必须有特定的逻辑。
您可以去掉所有点,但其他客户端可能会将点式电子邮件地址视为不同的。
我强烈建议不要尝试这样做,因为这将是一场维护噩梦,尤其是当其中一个电子邮件服务在一夜之间更改其策略时。此外,这种系统的好处很小,用户只会被激励去注册一个新的电子邮件地址,这仅比添加他们的实际电子邮件地址稍微困难一点。
Each email server will have varying rules about what is, and isn't allowed. You specified you don't want to have specific logic for each client, and for this reason you have to have specific logic.
You could strip out all dots, but other clients might count dotted email addresses as distinct.
I would highly recommend not attempting to try this, as it will be a maintenance nightmare, especially when overnight one of the email services changes their policy. Also, the benefits of such a system are small, users would just be motivated to register a new email address which is only marginally more difficult than dotting their actual one.
这是不可能的,因为每个单独的电子邮件服务可能会选择以自己的方式解释电子邮件地址的“本地部分”(
@
之前的部分)。[电子邮件受保护]
和< a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4c2f242d2821233e2d220c2b212d2520622f2321">[email protected]
可能会路由到同一邮箱,但不同的提供商可能会将它们路由到不同的邮箱。来自维基百科:
This is not possible as each individual email service may choose to interpret the "local part" of the email address (the portion before the
@
) it's own way.[email protected]
and[email protected]
may route to the same mailbox, but a different provider may route them to separate mailboxes.From wikipedia: