This commit is contained in:
2025-05-21 14:28:33 +00:00
parent 38811dbf23
commit 10ab09894b
8 changed files with 652 additions and 162 deletions

View File

@ -131,22 +131,27 @@ export const SMTP_DEFAULTS = {
*/
export const SMTP_PATTERNS = {
// Match EHLO/HELO command: "EHLO example.com"
// Made very permissive to handle various client implementations
EHLO: /^(?:EHLO|HELO)\s+(.+)$/i,
// Match MAIL FROM command: "MAIL FROM:<user@example.com> [PARAM=VALUE]"
MAIL_FROM: /^MAIL\s+FROM:<([^>]*)>((?:\s+\w+(?:=\w+)?)*)$/i,
// Made more permissive with whitespace and parameter formats
MAIL_FROM: /^MAIL\s+FROM\s*:\s*<([^>]*)>((?:\s+[a-zA-Z0-9][a-zA-Z0-9\-]*(?:=[^\s]+)?)*)$/i,
// Match RCPT TO command: "RCPT TO:<user@example.com> [PARAM=VALUE]"
RCPT_TO: /^RCPT\s+TO:<([^>]*)>((?:\s+\w+(?:=\w+)?)*)$/i,
// Made more permissive with whitespace and parameter formats
RCPT_TO: /^RCPT\s+TO\s*:\s*<([^>]*)>((?:\s+[a-zA-Z0-9][a-zA-Z0-9\-]*(?:=[^\s]+)?)*)$/i,
// Match parameter format: "PARAM=VALUE"
PARAM: /\s+([A-Za-z0-9][A-Za-z0-9\-]*)(?:=([^\s]+))?/g,
// Match email address format
EMAIL: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
// Match email address format - made much more permissive
// This only does very basic format validation to avoid rejecting valid addresses
// According to RFC 5321, we should accept a wide variety of sender formats
EMAIL: /^[^\s@]+(@[^\s@]+\.[^\s@]+)?$/,
// Match end of DATA marker: \r\n.\r\n
END_DATA: /\r\n\.\r\n$/,
// Match end of DATA marker: \r\n.\r\n or just .\r\n at the start of a line (to handle various client implementations)
END_DATA: /(\r\n\.\r\n$)|(\n\.\r\n$)|(\r\n\.\n$)|(\n\.\n$)|^\.(\r\n|\n)$/,
};
/**