Skip to content

Commit

Permalink
Return first, rather than last, response for pipelined SMTP commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Valodim committed Dec 5, 2018
1 parent 8b3d516 commit 64c6a14
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ private void executePipelinedCommands(Queue<String> pipelinedCommands) throws IO
private void readPipelinedResponse(Queue<String> pipelinedCommands) throws IOException, MessagingException {
String responseLine;
List<String> results = new ArrayList<>();
NegativeSmtpReplyException negativeRecipient = null;
NegativeSmtpReplyException firstNegativeResponse = null;
for (String command : pipelinedCommands) {
results.clear();
responseLine = readCommandResponseLine(results);
Expand All @@ -665,18 +665,18 @@ private void readPipelinedResponse(Queue<String> pipelinedCommands) throws IOExc
if (command.equals("DATA")) {
throw exception;
}
if (command.startsWith("RCPT")) {
negativeRecipient = (NegativeSmtpReplyException) exception;
if (command.startsWith("RCPT") && firstNegativeResponse == null) {
firstNegativeResponse = (NegativeSmtpReplyException) exception;
}
}
}

if (negativeRecipient != null) {
if (firstNegativeResponse != null) {
try {
executeCommand(".");
throw negativeRecipient;
throw firstNegativeResponse;
} catch (NegativeSmtpReplyException e) {
throw negativeRecipient;
throw firstNegativeResponse;
}
}

Expand Down

0 comments on commit 64c6a14

Please sign in to comment.