tags:

views:

159

answers:

5

Ive seen some php examples of how you can ping an inbox(without sending any mail to it) to check whether it exists. I was wondering if anyone knows if this is possible with .net? If it is Im going to write an app to do a bulk check on list of emails i have captured through my site.

+2  A: 

What you mean about if you writing "check email"? Without sending some unique link for email owner you can't check this, you can only check syntax of email, and connection to smtp.

public static bool isEmail(string inputEmail)
{
   inputEmail  = NulltoString(inputEmail);
   string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
         @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + 
         @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
   Regex re = new Regex(strRegex);
   if (re.IsMatch(inputEmail))
    return (true);
   else
    return (false);
}

smtp check

string[] host = (address.Split('@'));
string hostname = host[1];

IPHostEntry IPhst = Dns.Resolve(hostname);
IPEndPoint endPt = new IPEndPoint(IPhst.AddressList[0], 25);
Socket s= new Socket(endPt.AddressFamily, 
        SocketType.Stream,ProtocolType.Tcp);
s.Connect(endPt);
Svisstack
@Svisstack, check my answer for a more exact syntax check.
Brad
+1 for the hostname resolution
Brad
A: 

This is not foolproof. The best you can do is check syntax and see if the domain name resolves.

Email syntax RegEx: (?<username>#?[_a-zA-Z0-9-+]+(\.[_a-zA-Z0-9-+]+)*)@(?<domain>[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|arpa|asia|coop|info|jobs|mobi|museum|name|travel)))

Brad
Why the downvote?
Brad
+4  A: 

No, it is impossible in principle to check if an email exists - independent of language. There is simply no protocol to do it.

There are some partial solutions, but none of them are reliable.

See http://stackoverflow.com/questions/565504/how-to-check-if-an-email-address-exists-without-sending-an-email for details.

sleske
+11  A: 

SMTP defines a command for this, but since abuse by spammers totally overwhelmed the number of legitimate uses, virtually every e-mail server in the world is configured to lie.

Ben Voigt
+1 for explaining exactly why there is no reliable way to do what the OP wants. On a personal note, anything that makes bulk e-mail harder is unquestionably a good thing.
Joel Mueller
+1 dittoing @Joel
Brad
@Joel: Well, there *is* legitimate bulk mail (mailing lists etc.). But it's true that most bulk mail is illegitimate, even though that is deplorable.
sleske
A: 

The only option I can think of that would be guaranteed to work is to send someone an email to that address and then see if they respond. And yeah, that's a lot of work to go through for that.

mwgriffith
doesn't the original question say "without sending any mail to it"?
hawbsl
your right, I must have missed that the first time I read it.
mwgriffith