validating the domain of a mail address

  • Thread starter Thread starter ArunPrakash
  • Start date Start date
A

ArunPrakash

Hi All,
I have a case where i need to validate if the email address is valid
before i send a mail. for this there are 2 parts..
* check the format of mail address - this is done
* check the validity of the domain - for this do i need to connect to
domain name( example yahoo.com , port 25 )using TCP/Ip to the server
and then check to see if i receive correct responses. I am confused by
the use of SmtpServer in System.Web.Mail.. what is this server for??
If the machine in which i am working in allows all sockets to connect
can i directly create a tcp/ip socket and check the domain??
 
Arun,

You have to check whether your email address comply with RFC822.

RFC 822 checks Quoted Identifier, Local Part and Domain in any given email
address.

There are some samples available in c# to check that.

Shak.
 
I'd recommend not trying to validate. It's just not worth it. You can't use
the SmtpServer class for that; you'd have to open a socket, connect to the
server (the one that handles MX records for the domain you're sending to,
not the SMTP server) and do the whole thing manually.

The SmtpServer class is the address of the mail relay you use to send the
mail.

But yeah, you can do it manually over TCP/IP, sure.
 
Back
Top