Verify the correctness of the input
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 );
}
Verify the correctness of the email address:
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);
//attempting to connect
if (! Check_response (S, smtpresponse.connect_success))
{
S.close ();
return false;
}
//helo server
SendData (s, String. Format ("HELO {0}\r\n", Dns.gethostname ()));
if (! Check_response (S, smtpresponse.generic_success))
{
S.close ();
return false;
}
//identify yourself
//servers may resolve your domain and check whether your are listed in blacklists etc. SendData (S, String. Format ("MAIL from: {0}\r\n", "testexample@deepak.portland.co.uk"));
if (! Check_response (S, smtpresponse.generic_success))
{
S.close ();
return false;
}
//attempt Delivery (I can use VRFY, but most SMTP servers only disable it to security reasons)
SendData (s, address);
if (! Check_response (S, smtpresponse.generic_success))
{
S.close ();
return false;
}
Return (true);