dotnet-core_mail-server/MailServer/MailTransferAgent.cs

69 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using SMTPServer.Exceptions;
using System.Net;
using MailServer.SMTPServer;
namespace SMTPServer
{
class MailTransferAgent
{
/* public const string Hostname = "mail.fstamm.net";
private static MTACommandsDict MTACommandsDict = new MTACommandsDict();
private static Thread Thread;
private static List<MTASession> Sessions { get; set; }
public static void StartMailTransferAgent()
{
Thread = new Thread(new ThreadStart(MTA));
Thread.Start();
var portListener = new PortListener(25);
portListener.OnConnected += PortListener_OnConnected;
}
private static void PortListener_OnConnected(object source, ConnectedEventArgs e)
{
var session = new MTASession(e);
lock (Sessions)
{
Sessions.Add(session);
}
//throw new NotImplementedException();
}
public static void MTA()
{
while (true)
{
MailQueue.QueueMail mail = null;
try
{
MailQueue.GetNextMail();
}
catch (NoMailsInQueueException)
{
Thread.Sleep(100);
continue;
}
var charset = Encoding.UTF8;
var client = new StartTcpConnection(25, new IPAddress(mail.GetIpBytes()), charset);
if (!client.Connected) ; //ToDo Errorfall
}
}
public static string WaitForResponseCode(ResponseCodes code)
{
return null;
}*/
}
}