MailAddress with single
Possible Duplicate:
What characters are allowed in email address?
In C#, I don't know why MailAddress accept email address with single-quote, eg 'a''a'@gmail.com
... I also tested it in Hotmail and Gmail websites and they'll allow me to send an email to this wrong email addresses, but of course, later will get an failure email... even though during sign up, it doesn't allow new email with single quote '
... Did you know a valid email address that have single-quote? is it valid format?
sorry, I means single-quote
I would suggest you why don't you validate you email before you Send the email
This way you will get immediate feedback what is a valid email
Not the most ideal way to do it but you use the MailAddress class like this
MailAddress mailAddress = null;
try
{
mailAddress = new MailAddress("a'@gmail.com");//email address with single quote in it
}
catch(Exception exception)
{
//If emailAdress is not correct then warn user
}
As per RFC 2822, section 3.2.4, single quotes are allowed in email addresses (see how atext is defined):
atext = ALPHA / DIGIT / ; Any character except controls,
"!" / "#" / ; SP, and specials.
"$" / "%" / ; Used for atoms
"&" / "'" /
"*" / "+" /
"-" / "/" /
"=" / "?" /
"^" / "_" /
"`" / "{" /
"|" / "}" /
"~"
You may also want to quickly check your dubious email addresses against our free email validation service, that strictly follows the aforementioned RFC (among others) and is based on our email validation component for Microsoft .NET.
链接地址: http://www.djcxy.com/p/92860.html上一篇: ASP.NET电子邮件验证器正则表达式
下一篇: MailAddress与单个