Verify input correctness
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 you 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 for security reasons)
Senddata (S, address );
If (! Check_response (S, smtpresponse. generic_success ))
{
S. Close ();
Return false;
}
Return (true );