如何从邮件服务器验证电子邮件地址? [英] How to validate email address from mail server?

查看:139
本文介绍了如何从邮件服务器验证电子邮件地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i希望验证电子邮件ID格式的电子邮件服务器。



example- sample @ gmail.com是否存在。



i希望通过SMTP Handshakes进行验证。所以我使用openssl.exe从c#运行命令,并使用streamwriter和streamreader在openssl中读取和写入coommand。但无法读取最后一行响应amd也无法在openssl命令promt上重新执行命令。



这是我的示例代码。



私有StreamWriter mOutStream = null;

private StreamReader mInStream = null;



处理newShell = new Process();

newShell.StartInfo.FileName =openssl.exe ;

newShell.StartInfo.Arguments =s_client -starttls smtp -crlf -connect smtp.gmail.com:587;

newShell.StartInfo.RedirectStandardInput = true;

newShell.StartInfo.RedirectStandardOutput = true;

newShell.StartInfo.UseShellExecute = false;

newShell.Start();

mOutStream = newShell.StandardInput;

mInStream = newShell.StandardOutput;



int read_int;

int x;

while(mInStream.Peek()> 0)

{

x = mInStream.Peek();

char [] buffer = new char [4096];

read_int = mInStream.Read(buffer,0,bu ffer.Length);

for(int i = 0;我< read_int; i ++)

{



line = line + buffer [i]; //不读取响应代码将被重现的最后一行,如220,250等等。
}

}

mOutStream.WriteLine(MAIL FROM example.com \\\\ n); //这是我的电子邮件ID



没有在openssl上写下一个命令。我应该做什么wrnog。

Hi All,

i want to validate email id form email server.

example- sample@gmail.com is exist or not.

i want to validate via SMTP Handshakes. so i am using openssl.exe to run command from c# and read and write the coommand in openssl using streamwriter and streamreader. but unavailable to read last line response amd also not unavailable to re-wrte command on openssl command promt.

this is my sample code.

private StreamWriter mOutStream = null;
private StreamReader mInStream = null;

Process newShell = new Process();
newShell.StartInfo.FileName = "openssl.exe";
newShell.StartInfo.Arguments = " s_client -starttls smtp -crlf -connect smtp.gmail.com:587";
newShell.StartInfo.RedirectStandardInput = true;
newShell.StartInfo.RedirectStandardOutput = true;
newShell.StartInfo.UseShellExecute = false;
newShell.Start();
mOutStream = newShell.StandardInput;
mInStream = newShell.StandardOutput;

int read_int;
int x;
while (mInStream.Peek()>0)
{
x = mInStream.Peek();
char[] buffer = new char[4096];
read_int = mInStream.Read(buffer, 0, buffer.Length);
for (int i = 0; i < read_int; i++)
{

line = line + buffer[i];// not reading the last line where response code will recived like 220,250 etc.
}
}
mOutStream.WriteLine("MAIL FROM example.com \r\n"); //here is my email id

not writing on next command on openssl. shall i am doing any thing wrnog.

推荐答案

基本上,你不能。

您可以验证该电子邮件地址是否有效格式地址 - 有很多正则表达式可以做到这一点: http://www.regular-expressions.info/email.html [ ^ ]



但您无法检查电子邮件是否存在并受到监控,除非发送电子邮件并获得回复。没有常用的机制拒绝电子邮件作为未知收件人 - 虽然有些系统确实做了那么多,但更多的事情没有做任何事情 - 除非用户阅读你的电子邮件并做出回应,你永远不会知道电子邮件是否是接收。 (我有一个完全有效的DontSendMeAnyCrap@MyDomain.com地址,但它会自动删除它收到的所有内容。)



主要问题是垃圾邮件发送者和网络钓鱼者想要知道真正的电子邮件地址 - 所以他们只向他们发送垃圾 - 并防止大多数系统只是吞下duff地址并删除电子邮件内容。



结果,你也做不到。
Basically, you can't.
You can validate that the email address is a valid format address - there are loads of regexes to do just that: http://www.regular-expressions.info/email.html[^]

But you can't check that an email exists and is monitored except by sending an email and getting a reply. There is no commonly used mechanism for rejecting an email as "unknown recipient" - though some systems do do just that many, many more don't do anything - and unless the user reads your email and responds you would never know if the email was received. (I have a DontSendMeAnyCrap@MyDomain.com address that is totally valid, but it auto-deletes everything that it receives for example).

The main problem is that spammers and phishers want to know "real" email addresses - so they only send their rubbish to them - and to prevent that most systems just "swallow" duff addresses and delete the email content.

As a result, you can't do it either.


这篇关于如何从邮件服务器验证电子邮件地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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