检查电子邮件地址是否属于雅虎?

时间:2013-07-31 07:47:38

标签: asp.net email yahoo

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:<myemail@yahoo.com>" + 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();
    }

嗨,此代码不适用于smtp yahoo服务器,但代码适用于gmail smtp服务器TcpClient tClient = new TcpClient("gmail-smtp-in.l.google.com", 25)

  

错误:已建立的连接被主机中的软件中止,排队响应字符串= reader.ReadLine();

并且不会将端口服务器更改为25!     smtp服务器和端口服务器是否有效?     有没有办法确保电子邮件有效?     有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

某些服务器机器用于响应从其特定服务器获取数据的算法,而不是该机器无法响应......

但正如你所说gmail提供的数据因此机器不能对响应数据使用任何限制......