如何检查电子邮件ID是否存在 [英] How To check Email ID Exists Or Not

查看:129
本文介绍了如何检查电子邮件ID是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查电子邮件ID是否存在

现在,我正在检查是否存在任何电子邮件ID

我的主要问题是我没有Smtp服务器名称,例如("gmail-smtp-in.l.google.com")
因为我有多个域帐户

是否可以通过电子邮件ID获取Smtp服务器名称
或通过其他方式检查电子邮件ID帐户是否退出

在这里,我的代码仅检查Gmail帐户,但我有许多不同的电子邮件帐户

How To check Email ID Exists Or Not

Now I am Checking Any Email Id Exist Or Not

My Main Problem Is That I have No Smtp server name like ("gmail-smtp-in.l.google.com")
Because i Have Multiple Domain Account

If Any Way To Get Smtp Server Name From Email ID
Or Other Way To Check Email ID Account Exits OR Not

Here My Code It Only Check Gmail Account But I Have Many different Email Accounts

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 AnkurHere" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
ResponseString = reader.ReadLine();

dataBuffer = BytesFromString("MAIL FROM:<abc@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)
   {
       label1.Text = "Mai Address Does not Exist !";
       label2.Text = "Original Error from Smtp Server" + ResponseString;
   }

/* QUITE CONNECTION */
dataBuffer = BytesFromString("QUITE" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
tClient.Close();

推荐答案

无法检查它是否存在.如果域部分中指示的域存在并且邮件传递代理实际在其上运行,则无论如何它都会收到您的消息.接下来发生什么?这取决于.一些代理商可能会发回您的消息,并指出未找到收件人,但其他代理商将完全忽略此通信.即使发送了交付失败"通知,您通常也会很快但不是立即收到通知,因此很难按需使用它.

例如,我网站上的邮件系统可以将用户名不正确的所有邮件放在一个特殊的容器中,以便以后查看,或者可以自动回复此类邮件.如您所见,它都是可选的;和不同的组织使用不同的选项,没有响应可能是最典型的.

-SA
There is no a way to check it it exists or not. If the domain indicated in the domain part exists and the mail delivery agent actually operates on it, it will get your message anyway. What happens next? It depends. Some agents may send your message back and indicate that the addressee is not found, but others will ignore this communication altogether. Even if the "failed to deliver" notification is sent, you usually receive it pretty quickly, but not immediately, so it hardly can be used as you wanted.

For example, a mail system on my site could put all messages with incorrect user names in a special container so I could look it through later, or I could send an auto reply to such messages. As you can see, it is all optional; and different organization use different options, no response being probably most typical.

—SA


尽管您无法检查域中是否存在特定帐户,但至少可以检查指定的服务器是否存在:例如System.Net.NetworkInformation.Ping类,请参见 http://msdn.microsoft.com/zh-CN/library/system.net.networkinformation.ping%28v=vs.100%29.aspx [
Though you cannot check that a specific account exists on a domain, you could at least check that the specified server exists: use e.g. the System.Net.NetworkInformation.Ping class, see http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping%28v=vs.100%29.aspx[^]


这篇关于如何检查电子邮件ID是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆