谁帮帮我把这个程序改成java版的 ?
谢谢了 !
public int checkEmail(string mailAddress)
{
Regex reg=new Regex("^[a-zA-Z0-9_-]+@([a-zA-Z0-9-]+\\.){1,}(com|net|edu|miz|biz|cn|cc)$"); if(!reg.IsMatch(mailAddress) return 405;//Email地址形式上就不对
string mailServer=getMailServer(mailAddress);
if(mailServer==null)
{
return 404; //邮件服务器探测错误
}
TcpClient tcpc=new TcpClient();
tcpc.NoDelay=true;
tcpc.ReceiveTimeout=3000;
tcpc.SendTimeout=3000;
try{
tcpc.Connect(mailServer,25);
NetworkStream s=tcpc.GetStream();
StreamReader sr=new StreamReader(s,Encoding.Default);
StreamWriter sw=new StreamWriter(s,Encoding.Default);
string strResponse="";
string strTestFrom="[email protected]";
sw.WriteLine("helo "+mailServer);
sw.WriteLine("mail from:<"+mailAddress+">");
sw.WriteLine("rcpt to:<"+strTestFrom+">");
strResponse=sr.ReadLine();
if(!strResponse.StartsWith("2")) return 403; //用户名有误
sw.WriteLine("quit");
return 200; //Email地址检查无误
}catch(Exception ee)
{
return 403;//发生错误或邮件服务器不可达
}
}
上面有 几个类找不到 ??
StreamWriter,NetworkStream ,TcpClient,Regex
谢谢了 !
public int checkEmail(string mailAddress)
{
Regex reg=new Regex("^[a-zA-Z0-9_-]+@([a-zA-Z0-9-]+\\.){1,}(com|net|edu|miz|biz|cn|cc)$"); if(!reg.IsMatch(mailAddress) return 405;//Email地址形式上就不对
string mailServer=getMailServer(mailAddress);
if(mailServer==null)
{
return 404; //邮件服务器探测错误
}
TcpClient tcpc=new TcpClient();
tcpc.NoDelay=true;
tcpc.ReceiveTimeout=3000;
tcpc.SendTimeout=3000;
try{
tcpc.Connect(mailServer,25);
NetworkStream s=tcpc.GetStream();
StreamReader sr=new StreamReader(s,Encoding.Default);
StreamWriter sw=new StreamWriter(s,Encoding.Default);
string strResponse="";
string strTestFrom="[email protected]";
sw.WriteLine("helo "+mailServer);
sw.WriteLine("mail from:<"+mailAddress+">");
sw.WriteLine("rcpt to:<"+strTestFrom+">");
strResponse=sr.ReadLine();
if(!strResponse.StartsWith("2")) return 403; //用户名有误
sw.WriteLine("quit");
return 200; //Email地址检查无误
}catch(Exception ee)
{
return 403;//发生错误或邮件服务器不可达
}
}
上面有 几个类找不到 ??
StreamWriter,NetworkStream ,TcpClient,Regex
解决方案 »
- 网页的验证码!
- 如何把Struts2.0整合到MyEclipse中
- resin能发布的程序,为什么tomcat 发布不了?
- 悬赏200分◎!!!!IIS与Tomcat整合后,如何解决直接输入域名(如http://www.aaa.com)无法跳转到index.jsp的默认页?
- 帮我介绍工作,成功入职的,付一月工资做为酬谢(北京地区)
- 怎样才能在 打印 时把 下拉列表框 右边的 三角形箭头 隐藏?急呀!!!
- 如何利用jsp删除一个文件!
- jsp中统计两张表记录总数的select语句应该如何写
- 请帮我看一个jdbc bean的代码
- 关于堆的内存机制?
- 100000火急,______??????????如何防止重复投票???
- 对这个报错无语......你们来凭凭理!
他可以自动帮你引入相应的库。
如果你的系统中没有这些库的话,只好去网上搜一下,然后找相应的jar文件。自己动手解决可以学到很多东西的。