简体   繁体   English

如何检查远程服务器上是否存在电子邮件收件箱

[英]How to check if email inbox exists on a remote server

Is there an API to check if an email inbox exists on a remote server? 是否有API来检查远程服务器上是否存在电子邮件收件箱? my-addr.com does this beautifully and brings up some surprisingly high-level info about a box. my-addr.com做得非常漂亮,并提出了一些关于盒子的令人惊讶的高级信息。

  • john@gmail.com : "The email account that you tried to reach is over quota. Please direct" john@gmail.com :“您尝试覆盖的电子邮件帐户超过了配额。请直接”
  • whatsup@gmail.com : "gsmtp / e-mail exist" whatsup@gmail.com :“gsmtp /电子邮件存在”
  • asdfasdf19293949@gmail.com : "The email account that you tried to reach does not exist." asdfasdf19293949@gmail.com :“您尝试访问的电子邮件帐户不存在。”

The tool I linked to calls the process "reverse email lookup", but searching for the same brings up "finding a person from an email address" and other such tools. 我链接的工具调用流程“反向电子邮件查找”,但搜索相同的工具会显示“从电子邮件地址中查找人员”和其他此类工具。

How does this work? 这是如何运作的? Is there a way to do this directly from PHP or C#? 有没有办法直接从PHP或C#执行此操作?

I think you will find that many times these functions will lie to you to defeat spammers. 我想你会发现很多时候这些功能都会欺骗垃圾邮件发送者。 If there was a method to confirm if an email is real other than having a user click on a validation (or unsubscribe....) link then spammers would use it all the time 如果有一种方法来确认电子邮件是否真实,而不是让用户点击验证(或取消订阅....)链接,那么垃圾邮件发送者会一直使用它

The best way to verify an email address is to send a user an email containing a link, and have them click the link to verify that they received the email. 验证电子邮件地址的最佳方法是向用户发送包含链接的电子邮件,并让他们单击该链接以验证他们是否收到了电子邮件。 That said your only options would be the SMTP RCPT TO or VRFY commands. 那说你唯一的选择是SMTP RCPT TO或VRFY命令。

RCPT TO could be a way to check, as long as you disconnect after issuing it. RCPT TO可以是一种检查方式,只要您在发布后断开连接即可。 However not all servers will boot you if the account doesn't exist 但是,如果该帐户不存在,并非所有服务器都会引导您

VRFY can tell you if an account exists on that server, but is almost always disabled to prevent account probes. VRFY可以告诉您该服务器上是否存在帐户,但几乎总是被禁用以防止帐户探测。

A PHP class that does RCPT TO verification is: http://code.google.com/p/php-smtp-email-validation/ 执行RCPT TO验证的PHP类是: http//code.google.com/p/php-smtp-email-validation/

I do not see anything in my-addr.com's TOU that prohibits using it programatically: since you are happy with the site's results, you could consider (ie weigh technically, legally, and ethically) using my-addr.com itself as an "API". 我在my-addr.com的TOU中没有看到禁止以编程方式使用它的任何内容:因为您对网站的结果感到满意,您可以考虑使用my-addr.com本身作为“对技术,法律和道德的权衡”。 API”。

As a starting point, here is Fiddler Request to Code C# for a quick mailbox-existence check I performed: 作为一个起点,这里是Fiddler 请求代码 C#进行快速邮箱存在检查我执行:

private void MakeRequests()
{
    HttpWebResponse response;

    if (Request_my_addr_com(out response))
    {
        response.Close();
    }
}

private bool Request_my_addr_com(out HttpWebResponse response)
{
    response = null;

    try
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://my-addr.com/email/?mail=baz%40gmail.com&x=0&y=0");

        request.KeepAlive = true;
        request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
        request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36";
        request.Referer = "http://my-addr.com/email/?mail=foo%40gmail.com&x=15&y=12";
        request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip,deflate,sdch");
        request.Headers.Set(HttpRequestHeader.AcceptLanguage, "en-US,en;q=0.8");
        request.Headers.Set(HttpRequestHeader.Cookie, @"PHPSESSID=ne655jvfdte82b94gn0oumegj6");

        response = (HttpWebResponse)request.GetResponse();
    }
    catch (WebException e)
    {
        if (e.Status == WebExceptionStatus.ProtocolError) response = (HttpWebResponse)e.Response;
        else return false;
    }
    catch (Exception)
    {
        if(response != null) response.Close();
        return false;
    }

    return true;
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM