Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted

1 solution

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.
 
Share this answer
 
Comments
CreativeJaipal 22-Jun-15 3:53am    
thanks for reply.

but openssl provide mechanism to comunicate with smtp server. i just want to use same mechanism in c#

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900