我们可以在asp.net中使用正则表达式验证电子邮件地址。现在,我们如何才能确定一个电子邮件地址是否真的存在呢?
例如,farzaneh@yahoo.com具有正确的电子邮件格式,但不存在。
此代码仅适用于Gmail SMTP:
protected void btnCheck_Click(object sender, EventArgs e)
{
TcpClient tClient = new TcpClient("gmail-smtp-in.l.google.com", 25);
string CRLF = "\r\n";
byte[] dataBuffer;
string ResponseString;
NetworkStream netStream = tClient.GetStream();
StreamReader reader = new StreamReader(netStream);
ResponseString = reader.ReadLine();
/* Perform HELO to SMTP Server and get Response */
dataBuffer = BytesFromString("HELO KirtanHere" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
ResponseString = reader.ReadLine();
dataBuffer = BytesFromString("MAIL FROM:<YourGmailIDHere@gmail.com>" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
ResponseString = reader.ReadLine();
/* Read Response of the RCPT TO Message to know from google if it exist or not */
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 !<br/><br/>");
Response.Write("<B><font color='red'>Original Error from Smtp Server :</font></b>" + ResponseString);
}
/* QUITE CONNECTION */
dataBuffer = BytesFromString("QUITE" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
tClient.Close();
}发布于 2014-09-09 20:41:20
我认为这是不可能的,因为大多数电子邮件应用程序都有防火墙或类似的东西来防止垃圾邮件攻击。
即使是垃圾邮件,也会在他们的网站上添加一张照片,这样他们就可以确定照片是否在您的电子邮件地址上打开。
验证电子邮件地址的最好方法是向用户发送验证码或链接,他们必须进行确认。
发布于 2014-09-09 20:36:56
我自己还没有做过,但我可以给你一个线索。
您可以先使用域名的MX记录检查。其次,通过与SMTP握手检查它是否验证了xxx@google.com,但是我记得它归结到服务器,如果它允许或不允许。
尝试此链接http://www.codeproject.com/Articles/5189/End-to-end-Email-Address-Verification-for-Applicat
发布于 2020-05-16 05:10:23
如果你的网站与身份提供商集成在一起,你需要考虑到,通常像Google,Yahoo这样的身份提供商不会分享这些信息,除非用户授权第三方这样做。通常,一旦您获得授权,您就会被重定向到网站(google、yahoo将使用用户名、电子邮件或身份提供商管理的任何其他标准进行身份验证),这取决于它们与您的应用程序共享的声明,您可以从您的授权令牌中读取电子邮件地址。希望这能有所帮助
https://stackoverflow.com/questions/25744732
复制相似问题