Start extension implementatiopn
This commit is contained in:
parent
68e0ac2ef0
commit
df48102215
@ -7,6 +7,7 @@ namespace MailServer
|
||||
public class Configuration
|
||||
{
|
||||
public const string Hostname = "localhost";
|
||||
public bool STARTTLS_Active = false;
|
||||
public const bool STARTTLS_Active = true;
|
||||
public const int MaxMessageSizeInKb = 500000;
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +69,13 @@ namespace MailServer.SMTPServer
|
||||
AUTH_LOGIN
|
||||
}
|
||||
|
||||
public enum Extensions
|
||||
{
|
||||
PIPELINING,
|
||||
SIZE,
|
||||
STARTTLS,
|
||||
}
|
||||
|
||||
public enum ResponseCodes
|
||||
{
|
||||
C211 = 211,
|
||||
|
@ -79,7 +79,7 @@ namespace MailServer.SMTPServer
|
||||
var res3 = context.Accounts.Where(x => x.Domain.Equals(domain) && x.CatchAll == true);
|
||||
if (res3.Count() < 1)
|
||||
{
|
||||
//ToDo unmöglich machen!!
|
||||
accountId = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -145,6 +145,22 @@ namespace MailServer.SMTPServer
|
||||
switch (command.Command.ToUpper())
|
||||
{
|
||||
case "EHLO":
|
||||
if (command.Parameters.Length < 1)
|
||||
{
|
||||
SendResponse(ResponseCodes.C501, "Hostname Required");
|
||||
return;
|
||||
}
|
||||
SenderHostname = command.Parameters[0];
|
||||
Initialized = true;
|
||||
SendExtensionResponse(Extensions.PIPELINING);
|
||||
|
||||
if (Configuration.STARTTLS_Active)
|
||||
{
|
||||
SendExtensionResponse(Extensions.STARTTLS);
|
||||
}
|
||||
|
||||
SendResponse(ResponseCodes.C250, "SIZE " + (Configuration.MaxMessageSizeInKb * 1000).ToString());
|
||||
return;
|
||||
case "HELO":
|
||||
if (command.Parameters.Length < 1)
|
||||
{
|
||||
|
@ -36,14 +36,18 @@ namespace MailServer.SMTPServer
|
||||
Worker.Start();
|
||||
}
|
||||
|
||||
public void SendExtensionResponse(Extensions extension) => SendResponse("250-" + extension.ToString());
|
||||
|
||||
public void SendResponse(ResponseCodes responseCode) => SendResponse(responseCode, "");
|
||||
|
||||
public void SendResponse(ResponseCodes responseCode, string args)
|
||||
public void SendResponse(ResponseCodes responseCode, string args) => SendResponse(((int)responseCode).ToString() + " " + args);
|
||||
|
||||
|
||||
public void SendResponse(string response)
|
||||
{
|
||||
var text = ((int)responseCode).ToString();
|
||||
Logging.AddLogMessage(Logging.LoggingType.DEBUG, "Send back: " + text + " " + args);
|
||||
text += " " + args +'\r' + '\n';
|
||||
var bytes = Encoding.UTF8.GetBytes(text);
|
||||
Logging.AddLogMessage(Logging.LoggingType.INFO, response);
|
||||
response += '\r' + '\n';
|
||||
var bytes = Encoding.UTF8.GetBytes(response);
|
||||
Stream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user