验证输入的正确性
public static bool isEmail( string inputEmail )
{
inputEmail = NulltoString( inputEmail );
string strRegex = @^( [azAZ_]+ )@( ( [[]{}[]{}[]{} )|( ( [azAZ]+ )+ ) )( [azAZ]{}|[]{} )( ]? )$;
Regex re = new Regex( strRegex );
if ( reIsMatch( inputEmail ) )
return ( true );
else
return ( false );
}
验证邮件地址的正确性
string[] host = ( addressSplit( @ ) );
string hostname = host[];
IPHostEntry IPhst = DnsResolve( hostname );
IPEndPoint endPt = new IPEndPoint( IPhstAddressList[] );
Socket s= new Socket( endPtAddressFamily SocketTypeStreamProtocolTypeTcp );
sConnect( endPt );
//Attempting to connect
if( !Check_Response( s SMTPResponseCONNECT_SUCCESS ) )
{
sClose( );
return false;
}
//HELO server
Senddata( s stringFormat( HELO {}rn DnsGetHostName( )) );
if( !Check_Response( s SMTPResponseGENERIC_SUCCESS ) )
{
sClose( );
return false;
}
//Identify yourself
//Servers may resolve your domain and check whether you are listed in BlackLists etc
Senddata( s stringFormat( MAIL From: {}rntestexampleuk ) );
if( !Check_Response( s SMTPResponseGENERIC_SUCCESS ) )
{
sClose( );
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 SMTPResponseGENERIC_SUCCESS ) )
{
sClose( );
return false;
}
return ( true );