using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net.Mail;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace SMTP测试
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        bool b = false;

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            ; i < ; i++)
            {
                Thread th = new Thread(new ThreadStart(delegate
                {
                    Console.WriteLine(CheckSmtp(, "user", "pswd"));
                }));
                th.IsBackground = true;
                th.Start();
            }

        }
        private bool CheckSmtp(string smtpServer, int port, string username, string password)
        {
            TcpClient tcpClient = new TcpClient(smtpServer, port);
            NetworkStream stream = tcpClient.GetStream();

            ")) return false;

            SendCommand(stream, "HELO 211.152.50.xxx\r\n");
            ")) return false;

            SendCommand(stream, "AUTH LOGIN\r\n");
            ")) return false;

            SendCommand(stream, Base64Encode(username) + "\r\n");
            ")) return false;

            SendCommand(stream, Base64Encode(password) + "\r\n");
            ")) return false;

            return true;

        }

        private bool WaiteFor(NetworkStream stream, string strCode)
        {
            int StreamSize;
            ];
            StreamSize = stream.Read(ReadBuffer, , ReadBuffer.Length);
            , StreamSize);

            //Console.WriteLine(Returnvalue);

            , ).Equals(strCode);
        }
        private void SendCommand(NetworkStream stream, string strCmd)
        {
            byte[] WriteBuffer;

            WriteBuffer = Encoding.Default.GetBytes(strCmd);

            stream.Write(WriteBuffer, , WriteBuffer.Length);

        }

        private string Base64Encode(string str)
        {
            byte[] barray;
            barray = Encoding.Default.GetBytes(str);
            return Convert.ToBase64String(barray);
        }

    }
}

最新文章

  1. Python数据分析笔记目录
  2. 【iCore3 双核心板_FPGA】实验二十二:Niosii——固化程序到 EPCS 里
  3. 实现jQuery扩展总结
  4. poj -2010 Moo University - Financial Aid (优先队列)
  5. 51 nod 1006 最长公共子序列Lcs
  6. 内容替换Filter
  7. new Thread的弊端(转)
  8. PHP之运用CI用钩子实现URL权限控制————————【Badboy】
  9. IBM Mq Spring JMS 的xml配置
  10. 【Python】 发邮件用 smtplib &amp; email
  11. Charles(V3.10.1)的抓包以及常见功能的使用
  12. 获取页面所有a标签href
  13. python_day1_变量
  14. 数据库和ado连接语句的使用总结
  15. 安装和配置HyperServer
  16. ROM的一种写法
  17. 【原】公司P2P平台的功能拆分
  18. Discuz常见大问题-如何允许用户插入视频-如何允许用户在编辑帖子的时候带标签,允许用户插入视频
  19. 使用Consul做服务发现的若干姿势
  20. Servlet入门小案例

热门文章

  1. Angular2 小贴士 NgModule 模块
  2. 几道web前端练习题目
  3. iOS项目开发中的知识点与问题收集整理①(Part 一)
  4. 包含修改字体,图片上传等功能的文本输入框-Bootstrap
  5. Mybatis配置一对多的关联关系(五)
  6. Linux归档压缩、分区管理与LVM管理
  7. DevExpress免费公开课,讲解即将发布的16.2新版功能
  8. UIView的layoutSubviews和drawRect方法何时调用
  9. dyld 加载 Mach-O
  10. Android中使用Notification实现宽视图通知栏(Notification示例二)