这是有效的电子邮件地址吗?

Gre*_*reg 10 javascript email jquery rfc

"Françoise Lefèvre"@example.com
Run Code Online (Sandbox Code Playgroud)

我正在阅读RFC 5321,试图真正理解什么是有效的电子邮件地址 - 而且我可能会让它变得比它需要的更难 - 但这一直困扰着我.

               i.e., within a quoted string, any
               ASCII graphic or space is permitted
               without blackslash-quoting except
               double-quote and the backslash itself.
Run Code Online (Sandbox Code Playgroud)

这是否意味着ASCII扩展字符集在引号内有效?或者这仅仅意味着标准的ASCII表

编辑 - 考虑到答案,这里有一个简单的jQuery 验证器,可以补充插件的内置电子邮件验证来检查字符.

jQuery.validator.addMethod("ascii_email", function( value, element ) { 
    // In compliance with RFC 5321, this allows all standard printing ASCII characters in quoted text.
    // Unquoted text must be ASCII-US alphanumeric or one of the following: ! # $ % & ' * + - / = ? ^ _ ` { | } ~   
    // @ and . get a free pass, as this is meant to be used together with the email validator

    var result = this.optional(element) || 
        (
            /^[\u002a\u002b\u003d\u003f\u0040\u0020-\u0027\u002d-u002f\u0030-\u0039\u0041-\u005a\u005e-\u007e]+$/.test(value.replace(/(["])(?:\\\1|.)*?\1/, "")) &&     
            /^[\u0020-\u007e]+$/.test(value.match(/(["])(?:\\\1|.)*?\1/, ""))   
        );
    return result;
}, "Invalid characters");
Run Code Online (Sandbox Code Playgroud)

该插件的内置验证看起来非常好,除了捕获无效字符.在这里列出的测试用例中,它只允许注释,折叠空格和缺少TDL的地址(即:@localhost,@ 255.255.255.255) - 所有这些我都可以轻松地生活.

Jam*_*ack 4

根据此 MSDN 页面,扩展 ASCII 字符目前无效,但有一个提议的规范可以改变这一点。

http://msdn.microsoft.com/en-us/library/system.net.mail.mailaddress(VS.90).aspx

重要的部分在这里:

Thomas Lee 是正确的,因为在电子邮件地址中引用的本地部分是有效的,并且如果不在引用的字符串中,某些邮件地址可能无效。然而,你们其他人提到的字符,例如元音变音和龙舌兰,并不在 ASCII 字符集中,它们是扩展 ASCII。在 RFC 2822(以及后续 RFC 5322 和 3696)中,dtext 规范(在引用的本地部分中允许)仅允许大多数 ASCII 值(RFC 2822,第 3.4.1 节),其中包括 33-90 和 94-126 范围内的值。RFC 5335 已提议允许在 addr-spec 中使用非 ascii 字符,但它仍然被标记为实验性的,因此在 MailAddress 中不受支持。