简体   繁体   English

我们如何使用asp.net 确定电子邮件地址是否真的存在?

[英]How can we find out if an email address really exists or not using asp.net?

We can validate an email address with a regular expression in asp.net.我们可以在 asp.net 中使用正则表达式验证电子邮件地址。 Now, how can we find that an email address really exists or not?现在,我们如何确定一个电子邮件地址是否真的存在?

For example, farzaneh@yahoo.com has correct email format but does not exist.例如,farzaneh@yahoo.com 有正确的电子邮件格式,但不存在。

This code only works with the Gmail SMTP:此代码仅适用于 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();
}

I don't think this is possible because most email applications have firewalls or something like that to prevent spam attacks.我认为这是不可能的,因为大多数电子邮件应用程序都有防火墙或类似的东西来防止垃圾邮件攻击。

Even spam mails add a photo which is located on their site so they can determine if the photo is opened on your email address or not.甚至垃圾邮件也会添加一张位于其网站上的照片,以便他们可以确定该照片是否在您的电子邮件地址中打开。

The best way to validate an email address is to send a validation code or link to the user which they have to confirm.验证电子邮件地址的最佳方法是向用户发送验证代码或链接,他们必须进行确认。

I have not done myself but I can give you a lead.我自己没有做过,但我可以给你一个线索。

You can use MX record check of the domain first.您可以先使用域的 MX 记录检查。 Second check through handshake with SMTP if it validate xxx@google.com however what I recall it comes down to the server if it allows you or not.如果它验证 xxx@google.com,则通过与 SMTP 的握手进行第二次检查,但是我记得它归结为服务器是否允许。

try this link http://www.codeproject.com/Articles/5189/End-to-end-Email-Address-Verification-for-Applicat试试这个链接http://www.codeproject.com/Articles/5189/End-to-end-Email-Address-Verification-for-Applicat

If your website is integrated with an identity provider, you need to consider that normally an Identity Provider like Google, Yahoo don't share that information unless the user authorizes the third party to do it.如果您的网站与身份提供者集成,您需要考虑到通常身份提供者(如 Google、雅虎)不会共享该信息,除非用户授权第三方这样做。 You normally get redirected to the website(google, yahoo to be authenticated using username, email, or any other criteria that the identity provider manages), as soon as you are authorized, depending on the claims that they share with your application you can read from your authorization token, the email address.您通常会在获得授权后立即重定向到该网站(谷歌、雅虎使用用户名、电子邮件或身份提供商管理的任何其他标准进行身份验证),具体取决于他们与您的应用程序共享的声明,您可以阅读从您的授权令牌,电子邮件地址。 Hope this helps希望这可以帮助

It is not really possible: some mail provider won't acknowledge an adress doesn't exist to protect existing email adresses from spammers.这是不可能的:某些邮件提供商不会承认地址不存在以保护现有电子邮件地址免受垃圾邮件发送者的侵害。

For example the VRFY and EXPN commands of the SMTP protocol (RFC 2821) are either ignored or error on most servers.例如,SMTP 协议 (RFC 2821) 的 VRFY 和 EXPN 命令在大多数服务器上要么被忽略,要么出错。 Although it could be useful, the toxic behavior of spammers render the feature unusable.尽管它可能很有用,但垃圾邮件发送者的有害行为使该功能无法使用。

Half-baked solution: send a mail.半生不熟的解决方案:发送邮件。 If it bounces, it doesn't exist.如果它反弹,它就不存在。 If it doesn't bounce, it exists or the mail server doesn't want you to know it doesn't exist for security reasons, and you can't really do anything about it apart from having some way to get the user to answer (link in mail, image in html mail for users not using text-only clients or/and who always download included images).如果它没有退回,它存在或者邮件服务器出于安全原因不想让你知道它不存在,除了有办法让用户回答之外,你真的不能做任何事情(邮件中的链接,html 邮件中的图像,供不使用纯文本客户端或/和始终下载包含图像的用户使用)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用C#将asp.net中的电子邮件发送到使用gmail地址的任何电子邮件地址 - How to send email in asp.net using c# to any email address using gmail address 在ASP.Net中,我可以查看会话ID是否存在其他会话或是否有效? - In ASP.Net, Can I find out if another session exists or is valid by a session Id? 如何在 ASP.NET 中找到根页面? - How can I find out the Root Page in ASP.NET? 如何使用Asp.Net MVC数据库中的电子邮件地址在邮政上发送电子邮件 - How to send an email on Postal using an email address from the database Asp.Net MVC 我还能如何使用ASP.NET通过电子邮件发送文件? - How else can I email a file using ASP.NET? 我可以使用 .net 检查电子邮件地址是否存在吗? - Can I check if an email address exists using .net? 使用email-address作为loginID登录asp.net应用程序 - Using email-address as loginID to sign on to an asp.net application 我如何在ex.html c#中使用extern html文件作为附件并将其发送到电子邮件地址? - How I can use a extern html file for a attachment in asp.net c# and send it to a email address? 如何在asp.net中验证电子邮件地址和密码是否正确? - How can i validate an email address and password is correct in asp.net? 如何在ASP.NET MVC 5中获取外部登录的电子邮件地址 - How to get Email address of external login in ASP.NET MVC 5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM