如何检查电子邮件的存在 [英] how to check the existence of the email

查看:86
本文介绍了如何检查电子邮件的存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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;




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));
     }

        }

















这是我用来检查gmail帐户是否存在工作的代码好,但我如何为所有电子邮件服务器制作此代码意味着雅虎,直播等









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

推荐答案

一般来说,没有办法检查某些电子邮件的存在邮件帐户,除了发送一些电子邮件并获得答案,即使帐户存在,您自然也许永远不会得到答案。这不是邮件系统的工作方式。



关于这一点:它会非常不安全,会邀请垃圾邮件。



-SA
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


这篇关于如何检查电子邮件的存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆