@@ -22,12 +22,15 @@ const ENHANCED_STATUS_CODES = {
2222 214 : '2.0.0' , // Help message
2323 220 : '2.0.0' , // Service ready
2424 221 : '2.0.0' , // Service closing transmission channel
25+ 235 : '2.7.0' , // Authentication successful
2526 250 : '2.0.0' , // Requested mail action okay, completed
2627 251 : '2.1.5' , // User not local; will forward
2728 252 : '2.1.5' , // Cannot VRFY user, but will accept message
29+ 334 : '3.7.0' , // Server challenge for authentication
2830 354 : '2.0.0' , // Start mail input; end with <CRLF>.<CRLF>
2931
3032 // Temporary failure codes (4xx)
33+ 420 : '4.4.2' , // Timeout or connection lost (non-standard, used by some servers)
3134 421 : '4.4.2' , // Service not available, closing transmission channel
3235 450 : '4.2.1' , // Requested mail action not taken: mailbox unavailable
3336 451 : '4.3.0' , // Requested action aborted: local error in processing
@@ -41,14 +44,19 @@ const ENHANCED_STATUS_CODES = {
4144 503 : '5.5.1' , // Bad sequence of commands
4245 504 : '5.5.4' , // Command parameter not implemented
4346 521 : '5.3.2' , // Machine does not accept mail
47+ 523 : '5.3.4' , // Message size exceeds server limit (non-standard, used by some servers)
4448 530 : '5.7.0' , // Authentication required
4549 535 : '5.7.8' , // Authentication credentials invalid
50+ 538 : '5.7.0' , // Must issue a STARTTLS command first (non-standard)
4651 550 : '5.1.1' , // Requested action not taken: mailbox unavailable
4752 551 : '5.1.6' , // User not local; please try forwarding
4853 552 : '5.2.2' , // Requested mail action aborted: exceeded storage allocation
4954 553 : '5.1.3' , // Requested action not taken: mailbox name not allowed
5055 554 : '5.6.0' , // Transaction failed
51- 556 : '5.1.10' // RCPT TO syntax error
56+ 555 : '5.5.4' , // MAIL FROM/RCPT TO parameters not recognized or not implemented
57+ 556 : '5.1.10' , // RCPT TO syntax error (non-standard)
58+ 557 : '5.7.1' , // Delivery not authorized (non-standard, used by some servers)
59+ 558 : '5.2.3' // Message too large for recipient (non-standard, used by some servers)
5260} ;
5361
5462// Skip enhanced status codes for initial greeting and HELO/EHLO responses
@@ -674,7 +682,27 @@ class SMTPConnection extends EventEmitter {
674682 }
675683
676684 // Use default mapping
677- return ENHANCED_STATUS_CODES [ code ] || '' ;
685+ if ( ENHANCED_STATUS_CODES [ code ] ) {
686+ return ENHANCED_STATUS_CODES [ code ] ;
687+ }
688+
689+ // 2xx fallback
690+ if ( code >= 200 && code < 300 ) {
691+ return '2.0.0' ;
692+ }
693+
694+ // 4xx (transient failure)
695+ if ( code >= 400 && code < 500 ) {
696+ return '4.0.0' ;
697+ }
698+
699+ // 5xx (permanent failure)
700+ if ( code >= 500 ) {
701+ return '5.0.0' ;
702+ }
703+
704+ // safeguard (non-spec; but should never occur)
705+ return '' ;
678706 }
679707
680708 /**
0 commit comments