Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Mail;
using System.IO;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Configuration;
using System.Net.Sockets;

C#
namespace Email_sender
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {

TcpClient tClient = new TcpClient("gmail-smtp-in.l.google.com", 25);
            string CRLF = "\r\n";
         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 KirtanHere" + CRLF);
         netStream.Write(dataBuffer, 0, dataBuffer.Length);
         ResponseString = reader.ReadLine();
         dataBuffer = BytesFromString("MAIL FROM:<haseebawan0@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:<"+txtemail1.Text.Trim()+">"+CRLF);
         netStream.Write(dataBuffer, 0, dataBuffer.Length);
        ResponseString = reader.ReadLine();
        if (GetResponseCode(ResponseString) == 550)
        {
            MessageBox.Show("ERRor!ITS not exist");
        }
        else
        {
            MessageBox.Show("Email Exist");

        }
        /* QUITE CONNECTION */
         dataBuffer = BytesFromString("QUITE" + CRLF);
         netStream.Write(dataBuffer, 0, dataBuffer.Length);
         tClient.Close();
     }
     private byte[] BytesFromString(string str)
     {
         return Encoding.ASCII.GetBytes(str);
     }
    private int GetResponseCode(string ResponseString)
     {
         return int.Parse(ResponseString.Substring(0, 3));
     }

        }








This is the code i use to check existence of gmail account its working fine and good but how i make this code for all email servers means yahoo,live,etc
Posted
Updated 27-Feb-15 4:12am
v2
Comments
ZurdoDev 27-Feb-15 9:53am    
You can't. You don't know if an email actually exists until the email hits the server in control of the domain.
Member 11024166 27-Feb-15 10:10am    
can u tell me to edit this code
John C Rayan 27-Feb-15 11:13am    
Time to read Telnet commands and then use them to check availability of emails.

1 solution

Generally, there is no a way to check up existence of some e-mail account except sending some e-mail and getting the answer, which you, naturally, may never get, even if the account exists. This is not how mail system works.

And thing about this: it would be very insecure, would invite spam.

—SA
 
Share this answer
 
v4
Comments
Maciej Los 27-Feb-15 14:35pm    
+5
Sergey Alexandrovich Kryukov 27-Feb-15 15:11pm    
Thank you, Maciej.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900