Unfortunately my开发者_Python百科 hMailServer can't send emails to Hotmail. How can I determine whether a given email address is Hotmail or not, to prevent the message from being lost.
Hotmail e-mails can be: * @live.com * @live.fr[pt][ru][etc] * @hotmail.com, * @live.com.jp * @msn.com * and many country TLD specific combinations involving MSN, Hotmail and Live.
It seems like it's impossible to use a regular expression to filter that.
Any ideas on how to detect whether an email addresses is in the Hotmail family of addresses?
This will work:
function bool IsHotmailAddress(string email) {
var r = new Regex(@"\@(live|hotmail)\.[a-z]{2,3}(\.[a-z]{2,3})?$", RegexOptions.IgnoreCase);
return r.IsMatch(email);
}
精彩评论