Skip to content

Commit

Permalink
respect first overall negative reply in smtp pipelining
Browse files Browse the repository at this point in the history
  • Loading branch information
Valodim committed Dec 10, 2018
1 parent bad3f20 commit fda70cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ private void readPipelinedResponse(Queue<String> pipelinedCommands) throws IOExc
String responseLine;
List<String> results = new ArrayList<>();
NegativeSmtpReplyException firstNegativeResponse = null;
boolean dataCommandOk = true;
for (String command : pipelinedCommands) {
results.clear();
responseLine = readCommandResponseLine(results);
Expand All @@ -663,17 +664,19 @@ private void readPipelinedResponse(Queue<String> pipelinedCommands) throws IOExc

} catch (MessagingException exception) {
if (command.equals("DATA")) {
throw exception;
dataCommandOk = false;
}
if (command.startsWith("RCPT") && firstNegativeResponse == null) {
if (firstNegativeResponse == null) {
firstNegativeResponse = (NegativeSmtpReplyException) exception;
}
}
}

if (firstNegativeResponse != null) {
try {
executeCommand(".");
if (dataCommandOk) {
executeCommand(".");
}
throw firstNegativeResponse;
} catch (NegativeSmtpReplyException e) {
throw firstNegativeResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,8 @@ public void sendMessagePipelining_without354ReplyforData_shouldThrow() throws Ex
transport.sendMessage(message);
fail("Expected exception");
} catch (NegativeSmtpReplyException e) {
assertEquals(554, e.getReplyCode());
assertEquals("no valid recipients given", e.getReplyText());
assertEquals(550, e.getReplyCode());
assertEquals("remote mail to <user2@localhost> not allowed", e.getReplyText());
}

server.verifyConnectionClosed();
Expand Down

0 comments on commit fda70cb

Please sign in to comment.