Cleaned & Hardened Email.cs

This commit is contained in:
2026-08-17 10:27:59 +10:00
parent d61c48f4ab
commit a8eb857f55

View File

@@ -1,29 +1,47 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace smtpproxy.net; namespace smtpproxy.net
public class Email
{ {
public string FromIP; public class Email
{
public string FromIP { get; set; }
public string sHELO { get; set; }
public string sMAIL { get; set; }
public string sDATA { get; set; }
public List<string> sRCPTs { get; set; }
public string sHELO; public Email()
{
FromIP = string.Empty;
sHELO = string.Empty;
sMAIL = string.Empty;
sDATA = string.Empty;
sRCPTs = new List<string>();
}
public string sMAIL; public string GetRecipientEmail(string sRCPTTo)
{
if (string.IsNullOrEmpty(sRCPTTo))
return string.Empty;
public string sDATA; string cleaned = sRCPTTo
.Replace("\r", "")
.Replace("\n", "")
.Replace("<", "")
.Replace(">", "")
.Trim();
public List<string> sRCPTs; if (cleaned.StartsWith("rcpt to:", StringComparison.OrdinalIgnoreCase))
{
cleaned = cleaned.Substring(8).Trim();
}
else if (cleaned.StartsWith("rcpt to", StringComparison.OrdinalIgnoreCase))
{
cleaned = cleaned.Substring(7).Trim();
}
public string GetRecipientEmail(string sRCPTTo) return cleaned.ToLowerInvariant();
{ }
return sRCPTTo.ToLower().Replace("rcpt to:", "").Replace("<", "") }
.Replace(">", "")
.Replace("\r", "")
.Replace("\n", "");
}
public Email()
{
sRCPTs = new List<string>();
}
} }