我们可以包含“”“”吗?签名作为电子邮件地址的一部分?
我想知道允许“+”字符作为电子邮件地址的一部分是一个好习惯吗? 我有一个用 Java 编写的应用程序,带有“+”号的电子邮件地址被转换为其他内容 当它在 Servlet 中被解析(url 编码/解码)时。
I was wondering is it a good practice to allow "+" character as a part of email address?
I have an app written in Java, and email address with "+" sign get converted to something else
when it is parsed (url encode/decode) in the Servlet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您询问当有人输入它作为电子邮件地址时是否应该接受它,答案是肯定的 - 使用
+
符号后跟字符串通常用作 地址标签,邮件将被发送到与不带标签(或带有任何标签)的地址相同的邮箱其他标签)。如果您正在设置电子邮件系统并想知道是否应该允许用户请求包含 + 的地址,您可能不应该这样做,因为人们可能会认为具有不同标签的电子邮件最终会出现在同一用户的邮箱中。
If you're asking whether you should accept it when someone inputs it as their email address, the answer is yes - the use of the
+
symbol followed by a string is commonly used as an address tag, mail for which will be delivered to the same mailbox as the address without the tag (or with any other tag).If you're setting up an email system and want to know if you should allow users to request an address with a + in it, you probably shouldn't, since people may assume that emails with different tags end up in the same user's mailbox.
我看到您标记了问题 regex,这意味着您正在使用正则表达式来获取有效的电子邮件地址。
不要那样做。几乎可以肯定,有效的电子邮件地址比您想象的要多。最好只是接受用户给你的任何东西,并冒着接受不正确的东西的风险,而不是冒着拒绝正确的东西的风险。
根据此网页,以下Perl正则表达式匹配e - 邮件地址(在删除任何评论并用空格替换后):
I see you tagged the question regex, which implies that you're using regular expressions to valid e-mail addresses.
Don't do that. There are almost certainly more valid e-mail addresses than you think there are. It's probably best just to accept whatever the user gives you and risk accepting something incorrect rather than risk rejecting something that's correct.
According to this web page, the following Perl regular expression matches e-mail addresses (after they've had any comments deleted and replaced by whitespace):