开发者

Is an email address valid that passes validation but bounces?

I use the Zend_Validate_EmailAddress to vali开发者_运维技巧date email addresses for my email program. It validates according to the RFC2822 - http://framework.zend.com/manual/en/zend.validate.set.html

My question is are these valid emails when they pass validation?

test@test.co. test@test.co.za. etc Note the full stop at the end.

I find that the validator passes these email addresses which are obviously wrong. I don't fully understand why this should pass can anyone help me?

Regards


The email addresses are not "obviously wrong"; a DNS name is allowed to end with a trailing . to indicate that it's absolute rather than relative.

[EDITED to add: The above may be misleading. In an email address, for SMTP at least, hostnames are always interpreted as fully-qualified -- i.e., "absolute". So there's never a need for a trailing . in the hostname part of an email address. However, the trailing . is still valid hostname syntax.]


Following is the regular expression that is recommended by rfc2822 :

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

This regex is time-consuming therefore I believe that Zend went with a simpler regex which unintentionally ignores the trailing fullstop.

Helpful links:
http://www.regular-expressions.info/email.html
http://regexpal.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜