diff --git a/greenmail-core/src/main/java/com/icegreen/greenmail/smtp/commands/RcptCommand.java b/greenmail-core/src/main/java/com/icegreen/greenmail/smtp/commands/RcptCommand.java index 1a81a873e9..91dda6d0fd 100644 --- a/greenmail-core/src/main/java/com/icegreen/greenmail/smtp/commands/RcptCommand.java +++ b/greenmail-core/src/main/java/com/icegreen/greenmail/smtp/commands/RcptCommand.java @@ -26,7 +26,7 @@ */ public class RcptCommand extends SmtpCommand { - static Pattern param = Pattern.compile("RCPT TO:\\s?<([^>]+)>", + static Pattern param = Pattern.compile("RCPT TO:\\s?<([^>]*)>.*", Pattern.CASE_INSENSITIVE); @Override diff --git a/greenmail-core/src/test/java/com/icegreen/greenmail/smtp/SMTPCommandTest.java b/greenmail-core/src/test/java/com/icegreen/greenmail/smtp/SMTPCommandTest.java index cc3002490d..6db22d12a3 100644 --- a/greenmail-core/src/test/java/com/icegreen/greenmail/smtp/SMTPCommandTest.java +++ b/greenmail-core/src/test/java/com/icegreen/greenmail/smtp/SMTPCommandTest.java @@ -125,4 +125,18 @@ public void mailSenderAUTHSuffix() throws IOException, MessagingException { } } + + @Test + public void rcptToWithParameter() throws IOException, MessagingException { + Session smtpSession = greenMail.getSmtp().createSession(); + + try (SMTPTransport smtpTransport = new SMTPTransport(smtpSession, smtpURL)) { + Socket smtpSocket = new Socket(hostAddress, port); // Closed by transport + smtpTransport.connect(smtpSocket); + assertThat(smtpTransport.isConnected()).isTrue(); + smtpTransport.issueCommand("MAIL FROM: ", -1); + smtpTransport.issueCommand("RCPT TO: NOTIFY=SUCCESS,FAILURE", -1); + assertThat(smtpTransport.getLastServerResponse()).isEqualToNormalizingWhitespace("250 OK"); + } + } }