From b6030ecd83daf817d1b21b66cdea652988d62ae4 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 3 Sep 2022 17:29:53 +0200 Subject: [PATCH] Handle SMTP 2xx --- .../java/com/sun/mail/smtp/SMTPTransport.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/sun/mail/smtp/SMTPTransport.java b/app/src/main/java/com/sun/mail/smtp/SMTPTransport.java index b0e3de71d3..aec06aa31f 100644 --- a/app/src/main/java/com/sun/mail/smtp/SMTPTransport.java +++ b/app/src/main/java/com/sun/mail/smtp/SMTPTransport.java @@ -2002,13 +2002,30 @@ public class SMTPTransport extends Transport { break; default: - // handle remaining 4xy & 5xy codes + // handle remaining 2xy, 4xy & 5xy codes if (retCode >= 400 && retCode <= 499) { // assume address is valid, although we don't really know validUnsent.add(ia); } else if (retCode >= 500 && retCode <= 599) { // assume address is invalid, although we don't really know invalid.add(ia); + } else if (retCode >= 200 && retCode <= 299) { + // see RFC 5321 section 4.3.2 + // assume address is valid, although we don't really know + valid.add(ia); + if (!reportSuccess) + break; + + // user wants exception even when successful, including + // details of the return code + + // create and chain the exception + sfex = new SMTPAddressSucceededException(ia, cmd, retCode, + lastServerResponse); + if (mex == null) + mex = sfex; + else + mex.setNextException(sfex); } else { // completely unexpected response, just give up if (logger.isLoggable(Level.FINE))