This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
     new ba8ee0326e JAMES-3525 SMTP submission should forbid sending emails 
with MimeMess… (#2630)
ba8ee0326e is described below

commit ba8ee0326e5dd825d383239a19e468046c5062b5
Author: Rene Cordier <rcord...@linagora.com>
AuthorDate: Mon Feb 10 16:08:44 2025 +0700

    JAMES-3525 SMTP submission should forbid sending emails with MimeMess… 
(#2630)
---
 .../apache/james/smtp/SmtpIdentityVerificationTest.java  | 15 ++++++++-------
 .../rfc8621/contract/VacationRelayIntegrationTest.scala  |  2 +-
 .../smtpserver/SenderAuthIdentifyVerificationHook.java   | 16 +++++++++++++++-
 .../test/java/org/apache/james/smtpserver/DSNTest.java   | 12 ++++++------
 .../org/apache/james/smtpserver/FutureReleaseTest.java   |  6 +++---
 .../test/java/org/apache/james/smtpserver/SMTPSTest.java |  2 +-
 .../java/org/apache/james/smtpserver/SMTPSaslTest.java   |  4 ++--
 .../java/org/apache/james/smtpserver/SMTPServerTest.java | 10 +++++-----
 .../james/smtpserver/SmtpMtPriorityMessageHookTest.java  |  4 ++--
 .../james/smtpserver/SmtpRequireTlsMessageHookTest.java  |  4 ++--
 .../java/org/apache/james/utils/SMTPMessageSender.java   |  5 +++--
 11 files changed, 48 insertions(+), 32 deletions(-)

diff --git 
a/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpIdentityVerificationTest.java
 
b/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpIdentityVerificationTest.java
index 6a5059939a..aec3211ed0 100644
--- 
a/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpIdentityVerificationTest.java
+++ 
b/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpIdentityVerificationTest.java
@@ -334,23 +334,24 @@ class SmtpIdentityVerificationTest {
     }
 
     @Test
-    void errorsShouldBeIgnoredWhenUnAuthed(@TempDir File temporaryFolder) 
throws Exception {
+    void messageWithMissingMimeMessageFromFieldShouldBeRejected(@TempDir File 
temporaryFolder) throws Exception {
         createJamesServer(temporaryFolder, SmtpConfiguration.builder()
             .requireAuthentication()
             .verifyIdentity());
 
         String message = """
-            FROM: \r
             subject: test\r
             \r
             content\r
             .\r
             """;
 
-        assertThatCode(() ->
+        assertThatThrownBy(() ->
             messageSender.connect(LOCALHOST_IP, 
jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
-                .sendMessageWithHeaders("u...@domain.tld", 
ImmutableList.of(USER), message))
-            .doesNotThrowAnyException();
+                .authenticate(USER, PASSWORD)
+                .sendMessageWithHeaders(USER, ImmutableList.of(USER), message))
+            .isInstanceOf(SMTPSendingException.class)
+            .hasMessageContaining("503 5.5.4 Missing From header");
     }
 
     @Test
@@ -406,7 +407,7 @@ class SmtpIdentityVerificationTest {
         assertThatThrownBy(() ->
             messageSender.connect(LOCALHOST_IP, 
jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
                 .authenticate(USER, PASSWORD)
-                .sendMessageNoSender(USER))
+                .sendMessageNoSender(USER, USER))
             .isEqualTo(new SMTPSendingException(SmtpSendingStep.Sender, "503 
5.7.1 Incorrect Authentication for Specified Email Address\n"));
     }
 
@@ -418,7 +419,7 @@ class SmtpIdentityVerificationTest {
 
         assertThatCode(() ->
             messageSender.connect(LOCALHOST_IP, 
jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
-                .sendMessageNoSender(USER))
+                .sendMessageNoSender(USER, USER))
             .doesNotThrowAnyException();
     }
 
diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/VacationRelayIntegrationTest.scala
 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/VacationRelayIntegrationTest.scala
index 2a588fba32..c27c782ad9 100644
--- 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/VacationRelayIntegrationTest.scala
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/VacationRelayIntegrationTest.scala
@@ -89,7 +89,7 @@ trait VacationRelayIntegrationTest {
     smtpClient.helo(DOMAIN)
     smtpClient.setSender(externalMail)
     smtpClient.rcpt("<" + USER_WITH_DOMAIN + ">")
-    smtpClient.sendShortMessageData("Reply-To: <" + externalMail + 
">\r\n\r\ncontent")
+    smtpClient.sendShortMessageData("From: " + externalMail + 
"\r\n\r\nReply-To: <" + externalMail + ">\r\n\r\ncontent")
     calmlyAwait.atMost(1, TimeUnit.MINUTES).untilAsserted(() => {
       val mails = getFakeSmtp.getMockSmtp.getConfigurationClient.listMails
       assertThat(mails).hasSize(1)
diff --git 
a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java
 
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java
index 5f908ffa33..5620c9563e 100644
--- 
a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java
+++ 
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java
@@ -36,9 +36,12 @@ import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.protocols.api.ProtocolSession;
 import org.apache.james.protocols.smtp.SMTPConfiguration;
+import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;
 import 
org.apache.james.protocols.smtp.core.AbstractSenderAuthIdentifyVerificationHook;
+import org.apache.james.protocols.smtp.dsn.DSNStatus;
 import org.apache.james.protocols.smtp.hook.HookResult;
+import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.rrt.api.CanSendFrom;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
@@ -141,7 +144,18 @@ public class SenderAuthIdentifyVerificationHook extends 
AbstractSenderAuthIdenti
             (nSession.verifyIdentity() == 
SMTPConfiguration.SenderVerificationMode.RELAXED && session.getUsername() != 
null);
         if (shouldCheck) {
             try {
-                return StreamUtils.ofNullable(mail.getMessage().getFrom())
+                Address[] fromAddresses = mail.getMessage().getFrom();
+
+                if (fromAddresses == null || fromAddresses.length == 0) {
+                    return HookResult.builder()
+                        .hookReturnCode(HookReturnCode.deny())
+                        .smtpReturnCode(SMTPRetCode.BAD_SEQUENCE)
+                        
.smtpDescription(DSNStatus.getStatus(DSNStatus.PERMANENT, 
DSNStatus.DELIVERY_INVALID_ARG)
+                            + " Missing From header")
+                        .build();
+                }
+
+                return StreamUtils.ofNullable(fromAddresses)
                     .distinct()
                     .flatMap(address -> doCheckMessage(session, address))
                     .findFirst()
diff --git 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/DSNTest.java
 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/DSNTest.java
index add23a0a01..1e0323da2e 100644
--- 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/DSNTest.java
+++ 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/DSNTest.java
@@ -97,7 +97,7 @@ class DSNTest {
         smtpProtocol.sendCommand("EHLO localhost");
         smtpProtocol.sendCommand("MAIL FROM: <bob@localhost> RET=HDRS 
ENVID=QQ314159");
         smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost> 
NOTIFY=SUCCESS,FAILURE,DELAY ORCPT=rfc822;orcpt@localhost");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithDSN\r\n.\r\n");
+        smtpProtocol.sendShortMessageData("From: bob@localhost\r\n\r\nSubject: 
test mail\r\n\r\nTest body testSimpleMailSendWithDSN\r\n.\r\n");
 
         Mail lastMail = testSystem.queue.getLastMail();
         assertThat(lastMail.dsnParameters())
@@ -126,7 +126,7 @@ class DSNTest {
         smtpProtocol.sendCommand("RCPT TO:<rcpt1@localhost> 
NOTIFY=SUCCESS,FAILURE,DELAY ORCPT=rfc822;orcpt1@localhost");
         smtpProtocol.sendCommand("RCPT TO:<rcpt2@localhost> 
NOTIFY=SUCCESS,FAILURE,DELAY ORCPT=rfc822;orcpt2@localhost");
         smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost>");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithDSN\r\n.\r\n");
+        smtpProtocol.sendShortMessageData("From: bob@localhost\r\n\r\nSubject: 
test mail\r\n\r\nTest body testSimpleMailSendWithDSN\r\n.\r\n");
 
         Mail lastMail = testSystem.queue.getLastMail();
         assertThat(lastMail.dsnParameters())
@@ -156,7 +156,7 @@ class DSNTest {
         smtpProtocol.sendCommand("EHLO localhost");
         smtpProtocol.sendCommand("MAIL FROM: <bob@localhost> RET=HDRS 
ENVID=QQ314159");
         smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost> 
ORCPT=rfc822;orcpt@localhost");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithDSN\r\n.\r\n");
+        smtpProtocol.sendShortMessageData("From: bob@localhost\r\n\r\nSubject: 
test mail\r\n\r\nTest body testSimpleMailSendWithDSN\r\n.\r\n");
 
         Mail lastMail = testSystem.queue.getLastMail();
         assertThat(lastMail.dsnParameters())
@@ -182,7 +182,7 @@ class DSNTest {
         smtpProtocol.sendCommand("EHLO localhost");
         smtpProtocol.sendCommand("MAIL FROM: <bob@localhost> RET=HDRS 
ENVID=QQ314159");
         smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost> 
NOTIFY=SUCCESS,FAILURE,DELAY");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithDSN\r\n.\r\n");
+        smtpProtocol.sendShortMessageData("From: bob@localhost\r\n\r\nSubject: 
test mail\r\n\r\nTest body testSimpleMailSendWithDSN\r\n.\r\n");
 
         Mail lastMail = testSystem.queue.getLastMail();
         assertThat(lastMail.dsnParameters())
@@ -208,7 +208,7 @@ class DSNTest {
         smtpProtocol.sendCommand("EHLO localhost");
         smtpProtocol.sendCommand("MAIL FROM: <bob@localhost> ENVID=QQ314159");
         smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost> 
NOTIFY=SUCCESS,FAILURE,DELAY ORCPT=rfc822;orcpt@localhost");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithDSN\r\n.\r\n");
+        smtpProtocol.sendShortMessageData("From: bob@localhost\r\n\r\nSubject: 
test mail\r\n\r\nTest body testSimpleMailSendWithDSN\r\n.\r\n");
 
         Mail lastMail = testSystem.queue.getLastMail();
         assertThat(lastMail.dsnParameters())
@@ -234,7 +234,7 @@ class DSNTest {
         smtpProtocol.sendCommand("EHLO localhost");
         smtpProtocol.sendCommand("MAIL FROM: <bob@localhost> RET=HDRS");
         smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost> 
NOTIFY=SUCCESS,FAILURE,DELAY ORCPT=rfc822;orcpt@localhost");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithDSN\r\n.\r\n");
+        smtpProtocol.sendShortMessageData("From: bob@localhost\r\n\r\nSubject: 
test mail\r\n\r\nTest body testSimpleMailSendWithDSN\r\n.\r\n");
 
         Mail lastMail = testSystem.queue.getLastMail();
         assertThat(lastMail.dsnParameters())
diff --git 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/FutureReleaseTest.java
 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/FutureReleaseTest.java
index a9b47900de..a8d2d72714 100644
--- 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/FutureReleaseTest.java
+++ 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/FutureReleaseTest.java
@@ -107,7 +107,7 @@ class FutureReleaseTest {
         smtpProtocol.sendCommand("EHLO localhost");
         smtpProtocol.sendCommand("MAIL FROM: <bob@localhost> HOLDFOR=83200");
         smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost>");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithFutureRelease\r\n.\r\n");
+        smtpProtocol.sendShortMessageData("From: bob@localhost\r\n\r\nSubject: 
test mail\r\n\r\nTest body testSimpleMailSendWithFutureRelease\r\n.\r\n");
 
         ManageableMailQueue.MailQueueIterator browse = 
testSystem.queue.browse();
         assertThat(browse.hasNext()).isTrue();
@@ -125,7 +125,7 @@ class FutureReleaseTest {
         smtpProtocol.sendCommand("EHLO localhost");
         smtpProtocol.sendCommand("MAIL FROM: <bob@localhost> 
HOLDUNTIL=2023-04-14T10:30:00Z");
         smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost>");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithFutureRelease\r\n.\r\n");
+        smtpProtocol.sendShortMessageData("From: bob@localhost\r\n\r\nSubject: 
test mail\r\n\r\nTest body testSimpleMailSendWithFutureRelease\r\n.\r\n");
 
         ManageableMailQueue.MailQueueIterator browse = 
testSystem.queue.browse();
         assertThat(browse.hasNext()).isTrue();
@@ -263,7 +263,7 @@ class FutureReleaseTest {
         smtpProtocol.sendCommand("EHLO localhost");
         smtpProtocol.sendCommand("MAIL FROM: <bob@localhost>");
         smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost>");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithFutureRelease\r\n.\r\n");
+        smtpProtocol.sendShortMessageData("From: bob@localhost\r\n\r\nSubject: 
test mail\r\n\r\nTest body testSimpleMailSendWithFutureRelease\r\n.\r\n");
 
         assertThat(testSystem.queue.getSize()).isEqualTo(1L);
     }
diff --git 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPSTest.java
 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPSTest.java
index a1c4e8cf6b..72efc084f5 100644
--- 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPSTest.java
+++ 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPSTest.java
@@ -99,7 +99,7 @@ class SMTPSTest {
         smtpProtocol.sendCommand("EHLO localhost");
         smtpProtocol.sendCommand("MAIL FROM: <bob@localhost>");
         smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost>");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithDSN\r\n.\r\n");
+        smtpProtocol.sendShortMessageData("From: bob@localhost\r\n\r\nSubject: 
test mail\r\n\r\nTest body testSimpleMailSendWithDSN\r\n.\r\n");
 
         Mail lastMail = testSystem.queue.getLastMail();
         
ImmutableList.copyOf(lastMail.getMessage().getHeader("Received")).forEach(System.out::println);
diff --git 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPSaslTest.java
 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPSaslTest.java
index f133692d86..0e8b515312 100644
--- 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPSaslTest.java
+++ 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPSaslTest.java
@@ -196,7 +196,7 @@ class SMTPSaslTest {
 
         client.setSender(USER.asString());
         client.addRecipient("m...@domain.org");
-        client.sendShortMessageData("Subject: test\r\n\r\nTest body 
testAuth\r\n");
+        client.sendShortMessageData("From: " + USER.asString() + 
"\r\n\r\nSubject: test\r\n\r\nTest body testAuth\r\n");
         client.quit();
 
         assertThat(testSystem.queue.getLastMail())
@@ -462,7 +462,7 @@ class SMTPSaslTest {
 
         client.setSender(USER2.asString());
         client.addRecipient("m...@domain.org");
-        client.sendShortMessageData("Subject: test\r\n\r\nTest body 
testAuth\r\n");
+        client.sendShortMessageData("From: " + USER2.asString() + 
"\r\n\r\nSubject: test\r\n\r\nTest body testAuth\r\n");
         client.quit();
 
         assertThat(testSystem.queue.getLastMail())
diff --git 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
index ecd1458f84..c7b82cb41c 100644
--- 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
+++ 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
@@ -1273,7 +1273,7 @@ public class SMTPServerTest {
             .isEqualTo(503);
 
         smtpProtocol.addRecipient("m...@sample.com");
-        smtpProtocol.sendShortMessageData("Subject: test\r\n\r\nTest body 
testAuth\r\n");
+        smtpProtocol.sendShortMessageData("From: " + sender + 
"\r\n\r\nSubject: test\r\n\r\nTest body testAuth\r\n");
 
         smtpProtocol.quit();
 
@@ -1314,7 +1314,7 @@ public class SMTPServerTest {
 
         smtpProtocol.setSender(sender);
         smtpProtocol.addRecipient("m...@sample.com");
-        smtpProtocol.sendShortMessageData("Subject: test\r\n\r\nTest body 
testAuth\r\n");
+        smtpProtocol.sendShortMessageData("From: " + sender + 
"\r\n\r\nSubject: test\r\n\r\nTest body testAuth\r\n");
 
         smtpProtocol.quit();
 
@@ -1399,7 +1399,7 @@ public class SMTPServerTest {
 
         smtpProtocol.setSender(sender);
         smtpProtocol.addRecipient("m...@sample.com");
-        smtpProtocol.sendShortMessageData("Subject: test\r\n\r\nTest body 
testAuth\r\n");
+        smtpProtocol.sendShortMessageData("From: " + sender + 
"\r\n\r\nSubject: test\r\n\r\nTest body testAuth\r\n");
 
         smtpProtocol.quit();
 
@@ -1471,7 +1471,7 @@ public class SMTPServerTest {
 
         smtpProtocol.setSender(sender);
         smtpProtocol.addRecipient("m...@sample.com");
-        smtpProtocol.sendShortMessageData("Subject: test\r\n\r\nTest body 
testAuth\r\n");
+        smtpProtocol.sendShortMessageData("From: " + sender + 
"\r\n\r\nSubject: test\r\n\r\nTest body testAuth\r\n");
 
         smtpProtocol.quit();
 
@@ -1779,7 +1779,7 @@ public class SMTPServerTest {
             .as("authenticated.. not reject")
             .isEqualTo(250);
 
-        smtpProtocol.sendShortMessageData("Subject: test\r\n\r\nTest body 
testDNSRBLNotRejectAuthUser\r\n");
+        smtpProtocol.sendShortMessageData("From: " + sender + 
"\r\n\r\nSubject: test\r\n\r\nTest body testDNSRBLNotRejectAuthUser\r\n");
 
         smtpProtocol.quit();
 
diff --git 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SmtpMtPriorityMessageHookTest.java
 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SmtpMtPriorityMessageHookTest.java
index 340429979a..f75f27fbc8 100644
--- 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SmtpMtPriorityMessageHookTest.java
+++ 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SmtpMtPriorityMessageHookTest.java
@@ -80,7 +80,7 @@ class SmtpMtPriorityMessageHookTest {
         smtpProtocol.sendCommand("EHLO localhost");
         smtpProtocol.sendCommand("MAIL FROM: <bob@localhost> MT-PRIORITY=" + 
inputPriorityValue);
         smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost>");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithMtPriority\r\n.\r\n");
+        smtpProtocol.sendShortMessageData("From: bob@localhost\r\n\r\nSubject: 
test mail\r\n\r\nTest body testSimpleMailSendWithMtPriority\r\n.\r\n");
 
         Mail lastMail = testSystem.queue.getLastMail();
 
@@ -133,7 +133,7 @@ class SmtpMtPriorityMessageHookTest {
         smtpProtocol.sendCommand("EHLO whatever.tld");
         smtpProtocol.sendCommand("MAIL FROM: <b...@whatever.tld> MT-PRIORITY=" 
+ priorityValue);
         smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost>");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithMtPriority\r\n.\r\n");
+        smtpProtocol.sendShortMessageData("From: 
b...@whatever.tld\r\n\r\nSubject: test mail\r\n\r\nTest body 
testSimpleMailSendWithMtPriority\r\n.\r\n");
 
         Mail lastMail = testSystem.queue.getLastMail();
 
diff --git 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SmtpRequireTlsMessageHookTest.java
 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SmtpRequireTlsMessageHookTest.java
index c470a97272..c259f04ebd 100644
--- 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SmtpRequireTlsMessageHookTest.java
+++ 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SmtpRequireTlsMessageHookTest.java
@@ -109,7 +109,7 @@ class SmtpRequireTlsMessageHookTest {
         client.sendCommand("EHLO localhost");
         client.sendCommand("MAIL FROM:<bob@localhost> REQUIRETLS");
         client.sendCommand("RCPT TO:<rcpt@localhost>");
-        client.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithMtPriority\r\n.\r\n");
+        client.sendShortMessageData("From: bob@localhost\r\n\r\nSubject: test 
mail\r\n\r\nTest body testSimpleMailSendWithMtPriority\r\n.\r\n");
 
         Mail lastMail = testSystem.queue.getLastMail();
 
@@ -125,7 +125,7 @@ class SmtpRequireTlsMessageHookTest {
         client.sendCommand("EHLO localhost");
         client.sendCommand("MAIL FROM:<bob@localhost> REQUIRETLS");
         client.sendCommand("RCPT TO:<rcpt@localhost>");
-        client.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithMtPriority\r\n.\r\n");
+        client.sendShortMessageData("From: bob@localhost\r\n\r\nSubject: test 
mail\r\n\r\nTest body testSimpleMailSendWithMtPriority\r\n.\r\n");
 
         Mail lastMail = testSystem.queue.getLastMail();
 
diff --git 
a/server/testing/src/main/java/org/apache/james/utils/SMTPMessageSender.java 
b/server/testing/src/main/java/org/apache/james/utils/SMTPMessageSender.java
index a6d3823925..9ee8ef6f35 100644
--- a/server/testing/src/main/java/org/apache/james/utils/SMTPMessageSender.java
+++ b/server/testing/src/main/java/org/apache/james/utils/SMTPMessageSender.java
@@ -138,11 +138,12 @@ public class SMTPMessageSender extends ExternalResource 
implements Closeable, Af
         return this;
     }
 
-    public SMTPMessageSender sendMessageNoSender(String recipient) throws 
IOException {
+    public SMTPMessageSender sendMessageNoSender(String from, String 
recipient) throws IOException {
         doHelo();
         doSetSender("");
         doAddRcpt(recipient);
-        doData("subject: test\r\n" +
+        doData("FROM: " + from + "\r\n" +
+            "subject: test\r\n" +
             "\r\n" +
             "content\r\n" +
             ".\r\n");


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to