如何删除重复的电子邮件地址

发布于 2024-11-07 05:26:47 字数 975 浏览 5 评论 0原文

有没有一种方法可以可靠地从用户输入的电子邮件地址中获取唯一的电子邮件地址?问题是,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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

极度宠爱 2024-11-14 05:26:47

每个电子邮件服务器对于允许和不允许的内容都有不同的规则。您指定不希望每个客户端都有特定的逻辑,因此您必须有特定的逻辑。

您可以去掉所有点,但其他客户端可能会将点式电子邮件地址视为不同的。

我强烈建议不要尝试这样做,因为这将是一场维护噩梦,尤其是当其中一个电子邮件服务在一夜之间更改其策略时。此外,这种系统的好处很小,用户只会被激励去注册一个新的电子邮件地址,这仅比添加他们的实际电子邮件地址稍微困难一点。

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.

薄荷梦 2024-11-14 05:26:47

这是不可能的,因为每个单独的电子邮件服务可能会选择以自己的方式解释电子邮件地址的“本地部分”(@ 之前的部分)。 [电子邮件受保护]< 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:

Interpretation of the local-part of an email address is dependent on the conventions and policies implemented in the mail server. For example, case-sensitivity may distinguish mailboxes differing only in capitalization of characters of the local-part, although this is not very common.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文