gpt4 book ai didi

c# - 检查电子邮件是否存在,自动重新连接 tcpclient c#

转载 作者:太空宇宙 更新时间:2023-11-03 12:09:27 24 4
gpt4 key购买 nike

我正在尝试使用 .NET 创建一个检查电子邮件是否存在的应用

想了2个小时也没想到什么办法

这个方案的目的是让我的服务器躲过ban或者exceed测试。

我的问题是如何在检查完电子邮件数量并从数组中的最后一封电子邮件继续后自动重新连接 TcpClient

public void isChecked(string[] MailCheck,string length)
{
//converte ArrayLength from string to int
int num = int.Parse(length);


TcpClient tClient = new TcpClient("smtp-in.orange.fr", 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 Contact" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
ResponseString = reader.ReadLine();
dataBuffer = BytesFromString("mail from:<contact@contact.com>" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
ResponseString = reader.ReadLine();

for (i = 0; i < num; i++)
{


/* Read Response of the RCPT TO Message to know from google if it exist or not */

dataBuffer = BytesFromString("rcpt to:<" + MailCheck[i] + ">" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
ResponseString = reader.ReadLine();
if (GetResponseCode(ResponseString) == 550)
{
//MessageBox.Show("false " + ResponseString);
System.Diagnostics.Debug.WriteLine("false || " + ResponseString);
}
else
{
//MessageBox.Show("true " + ResponseString);
System.Diagnostics.Debug.WriteLine("true || " + ResponseString);

System.IO.File.AppendAllText(@"C:/WarningsLog.txt", MailCheck[i] + Environment.NewLine);
}
}

最佳答案

你可以

  • 将收件人放入列表

  • 作为外部循环,在列表不为空时进行迭代。为避免无限循环,您可以考虑限制迭代次数。

  • 连接到 SMPT 服务器

  • 作为内循环,发送消息。当可以发送邮件时,从列表中删除收件人。如果发生暂时性错误,则退出内循环

您是否考虑过使用现有的 SMTP 客户端实现,例如 https://github.com/jstedfast/MailKit或者至少是 System.Net.SmtpClient?

关于c# - 检查电子邮件是否存在,自动重新连接 tcpclient c#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53137242/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com