2016-11-26 11:11:27 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using SMTPServer.Exceptions;
|
|
|
|
|
using System.Net;
|
2016-11-27 17:38:47 +00:00
|
|
|
|
using MailServer.SMTPServer;
|
2016-11-26 11:11:27 +00:00
|
|
|
|
|
|
|
|
|
namespace SMTPServer
|
|
|
|
|
{
|
|
|
|
|
class MailTransferAgent
|
|
|
|
|
{
|
2016-11-27 17:38:47 +00:00
|
|
|
|
/* public const string Hostname = "mail.fstamm.net";
|
2016-11-26 11:11:27 +00:00
|
|
|
|
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;
|
2016-11-27 17:38:47 +00:00
|
|
|
|
}*/
|
2016-11-26 11:11:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|