• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

C#验证邮件的正则表达式的代码_C#

c# 搞代码 3年前 (2018-08-10) 83次浏览 已收录 0个评论

验证输入的正确性

public static bool isEmail(string inputEmail)
{
inputEmail = NulltoString(inputEmail);
string strRegex = @"^([a-zA-Z0-9_/-/.]+)@((/[[0-9]{1,3}/.[0-9]{1,3}/.[0-9]{1,3}/.)|(([a-zA-Z0-9/-]+/.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(/]?)$";
Regex re = new Regex(strRegex);
if (re.IsMatch(inputEmail))
return (true);
else

http://www.gaodaima.com/66403.htmlc#验证邮件的正则表达式的代码_C#

return (false);
}

验证邮件地址的正确性:

string[] host = (address.Split(@));
string hostname = host[1];

IPHostEntry IPhst = Dns.Resolve(hostname);
IPEndPoint endPt = new IPEndPoint(IPhst.AddressList[0], 25);
socket s= new Socket(endPt.AddressFamily, SocketType.Stream,ProtocolType.tcp);
s.Connect(endPt);

//Attempting to connect
if(!Check_Response(s, SMTPResponse.CONNECT_SUCCESS))
{
s.Close();
return false;
}

//HELO server
Senddata(s, string.Format("HELO {0}/r/n", Dns.GetHostName() ));
if(!Check_Response(s, SMTPResponse.GENERIC_SUCCESS))
{
s.Close();
return false;
}

//Identify yourself
//Servers may resolve your domain and check whether you are listed in BlackLists etc.
Senddata(s, string.Format("MAIL From: {0}/r/n","[email protected]"));
if(!Check_Response(s, SMTPResponse.GENERIC_SUCCESS))
{

s.Close();
return false;
}

//Attempt Delivery (I can use VRFY, but most SMTP servers only disable it for security reasons)
Senddata(s, address);
if(!Check_Response(s, SMTPResponse.GENERIC_SUCCESS))
{

s.Close();
return false;
}
return (true);

欢迎大家阅读《C#验证邮件的正则表达式的代码_C#》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码


喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址