Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

mailbox exists c#

private static void Main(string[] args)
{            
  var gMail = IsEmailAccountValid("gmail-smtp-in.l.google.com", "aa.aa@gmail.com");
  Console.WriteLine($"Gmail account is valid - {gMail.ToString()}");

  var live = IsEmailAccountValid("live-com.olc.protection.outlook.com", "aa.aa@live.com");
  Console.WriteLine($"Live account is valid - {live.ToString()}");
}

private static byte[] BytesFromString(string str)
{
  return Encoding.ASCII.GetBytes(str);
}

private static int GetResponseCode(string ResponseString)
{
  return int.Parse(ResponseString.Substring(0, 3));
}

private static bool IsEmailAccountValid(string tcpClient, string emailAddress)
{
  TcpClient tClient = new TcpClient(tcpClient, 25);
  string CRLF = "
";
  byte[] dataBuffer;
  string ResponseString;
  NetworkStream netStream = tClient.GetStream();
  StreamReader reader = new StreamReader(netStream);
  ResponseString = reader.ReadLine();

  /* Perform HELO to SMTP Server and get Response */
  dataBuffer = BytesFromString("HELO Hi" + CRLF);
  netStream.Write(dataBuffer, 0, dataBuffer.Length);
  ResponseString = reader.ReadLine();
  dataBuffer = BytesFromString("MAIL FROM:<YourGmailIDHere@gmail.com>" + CRLF);
  netStream.Write(dataBuffer, 0, dataBuffer.Length);
  ResponseString = reader.ReadLine();

  /* Read Response of the RCPT TO Message to know from google if it exist or not */
  dataBuffer = BytesFromString($"RCPT TO:<{emailAddress}>" + CRLF);
  netStream.Write(dataBuffer, 0, dataBuffer.Length);
  ResponseString = reader.ReadLine();
  var responseCode = GetResponseCode(ResponseString);

  if (responseCode == 550)
  {
    return false;
  }

  /* QUITE CONNECTION */
  dataBuffer = BytesFromString("QUITE" + CRLF);
  netStream.Write(dataBuffer, 0, dataBuffer.Length);
  tClient.Close();
  return true;
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: typescript var global: typeof globalThis 
Typescript :: how to search for elements that are on the webpage using html 
Typescript :: gettime is not a function typescript 
Typescript :: conditional statements in linux 
Typescript :: mongodb move documents to another collection 
Typescript :: None of the following functions can be called with the arguments supplied. makeText(Context!, CharSequence!, Int) defined in android.widget.Toast makeText(Context!, Int, Int) defined in android.widget.Toast 
Typescript :: how to read excel spreadsheets in c++ 
Typescript :: show all value_counts pandas 
Typescript :: loop trhough list of lists in python and find single elements 
Typescript :: open dialog 
Typescript :: how to reset windows update components in windows 
Typescript :: kotlin get first n elements from list 
Typescript :: ts enum 
Typescript :: type definition method typescript 
Typescript :: split in angular 8 
Typescript :: ERROR in The Angular Compiler requires TypeScript =3.4.0 and <3.6.0 but 4.1.5 was found instead. 
Typescript :: angular bind colspan to ts variable 
Typescript :: react native mime type converter 
Typescript :: typescript equals string 
Typescript :: store all years in array angular 
Typescript :: How to stop error reporting in TypeScript? 
Typescript :: read and write objects in cpp 
Typescript :: What do HTTP requests and responses look like? 
Typescript :: typescript custom number no greater than x 
Typescript :: nextjs waiting for compiling problem 
Typescript :: typescript generic object not array 
Typescript :: what are the parts of an array called 
Typescript :: woocommerce remove This is where you can add new products to your store in taxonomy description 
Typescript :: formula: =concatenate(transpose(xxxxx)) highlight transpose (xxxx), press "ctrl" + "=" then delete front and back curly brackets "{ }" enter Add grepper answer 
Typescript :: webintent plugin cordova 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =