是否允许电子邮件地址包含非字母数字字符? [英] Are email addresses allowed to contain non-alphanumeric characters?

查看:411
本文介绍了是否允许电子邮件地址包含非字母数字字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Django构建一个网站。该网站可能拥有来自非英语国家的重要用户。



我只想知道电子​​邮件地址可能包含哪些类型的字符有什么技术限制。



电子邮件地址只允许包含英文字母,数字_,@和。?


$ b $是否允许包含非英文字母,如é或ü?



是否允许包含中文或日文或其他Unicode字符?

解决方案

电子邮件地址两个部分 本地之前@和



这些部分的规则是不同的:



对于本地部分您可以使用ASCII:




  • 拉丁字母A - Z a - z

  • 数字0 - 9

  • 特殊字符#$%&'* + - / =?^ _`{|}〜

  • <它不是第一个还是最后一个,而不是顺序
  • 空格和(),...;<> @ []字符是允许的限制(它们只允许在引用字符串,反斜杠或双引号之前必须有反斜杠)

  • Plus自2012年以来您可以使用国际上述字符 U + 007F ,编码为为UTF-8



域名更受限制:




  • 拉丁字母A - Z a - z

  • 数字0 - 9

  • 连字符 - 不是第一个或最后一个,允许连续的多个连字符。



正则表达式进行验证



^(([^]()\ [\] \。,;:\s @ \ ] +(。\ [^<>()\ [\] \。,;:\s @ \] +)* )|(。+ \ \))@(([^<>()[\] \;:\s @ \。] + \)+ [^。 <>()[\] \。,;:\s @ \] {2,})




I'm building a website using `Django. The website could have significant users from non-English speaking countries.

I just want to know if there are any technical restrictions on what types of characters an email address could contain.

Are email addresses only allowed to contain English alphabets, numbers, "_", "@" and "."?

Are they allowed to contain non-English alphabets like "é" or "ü"?

Are they allowed to contain Chinese or Japanese or other Unicode characters?

解决方案

Email address consists of two parts local before @ and domain that goes after.

Rules to these parts are different:

For local part you can use ASCII:

  • Latin letters A - Z a - z
  • digits 0 - 9
  • special characters !#$%&'*+-/=?^_`{|}~
  • dot ., that it is not first or last, and not in sequence
  • space and "(),:;<>@[] characters are allowed with restrictions (they are only allowed inside a quoted string, a backslash or double-quote must be preceded by a backslash)
  • Plus since 2012 you can use international characters above U+007F, encoded as UTF-8.

Domain part is more restricted:

  • Latin letters A - Z a - z
  • digits 0 - 9
  • hyphen -, that is not first or last, multiple hyphens in sequence are allowed.

Regex to validate

^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})

Hope this saves you some time.

这篇关于是否允许电子邮件地址包含非字母数字字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆