private byte[] BytesFromString(string str)
{
return Encoding.ASCII.GetBytes(str);
}
private int GetResponseCode(string ResponseString)
{
return int.Parse(ResponseString.Substring(0, 3));
}
protected void Button1_Click(object sender, EventArgs e)
{
TcpClient tClient = new TcpClient("plus.smtp.mail.yahoo.com", 465);
string CRLF = "\r\n";
byte[] dataBuffer;
string ResponseString;
NetworkStream netStream = tClient.GetStream();
StreamReader reader = new StreamReader(netStream);
ResponseString = reader.ReadLine();
dataBuffer = BytesFromString("HELO " + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
ResponseString = reader.ReadLine();
dataBuffer = BytesFromString("MAIL FROM:<[email protected]>" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
ResponseString = reader.ReadLine();
dataBuffer = BytesFromString("RCPT TO:<" + TextBox1.Text.Trim() + ">" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
ResponseString = reader.ReadLine();
if (GetResponseCode(ResponseString) == 550)
{
Response.Write("Mai Address Does not Exist !");
}
dataBuffer = BytesFromString("QUITE" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
tClient.Close();
}
안녕,이 코드는 Gmail의 SMTP 서버 TcpClient tClient = new TcpClient("gmail-smtp-in.l.google.com", 25)
이메일 주소가 Yahoo에 속하는 지 확인 하시겠습니까?
error:An established connection was aborted by the software in your host machine in line Response String = reader.ReadLine();
와 SMTP 야후 서버하지만 코드가 작동 작업 25 발생하지에 포트 서버를 변경하지 않습니다! smtp 서버와 포트 서버가 유효한지 여부 이메일이 유효한지 확인하는 방법이 있습니까? 누군가 나를 도울 수 있습니까?
다음을 참조하십시오. http://stackoverflow.com/questions/3040104/verify-that-email-domain-exists –