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