From c752bfa0e4da157caa1e0847774ce5e664b20b2d Mon Sep 17 00:00:00 2001 From: Benoit TELLIER Date: Mon, 9 Feb 2026 23:44:20 +0100 Subject: [PATCH] JAMES-4171 Allow configure strong distinction between submission and mx ports --- .../servers/partials/configure/smtp.adoc | 12 +++++++++ .../protocols/lmtp/LMTPConfigurationImpl.java | 5 ++-- .../protocols/smtp/SMTPConfiguration.java | 7 ++++-- .../protocols/smtp/SMTPConfigurationImpl.java | 5 ++-- .../sample-configuration/smtpserver.xml | 2 ++ .../sample-configuration/smtpserver.xml | 2 ++ .../sample-configuration/smtpserver.xml | 2 ++ .../sample-configuration/smtpserver.xml | 2 ++ .../configuration/SmtpConfiguration.java | 12 +++++++++ .../src/main/resources/smtpserver.xml | 2 ++ .../smtp/SmtpIdentityVerificationTest.java | 25 +++++++++++++++++++ .../james/lmtpserver/netty/LMTPServer.java | 7 +++--- .../james/smtpserver/ExtendedSMTPSession.java | 5 ++-- .../SenderAuthIdentifyVerificationHook.java | 14 +++++++---- .../james/smtpserver/netty/SMTPServer.java | 14 +++++------ src/site/xdoc/server/config-smtp-lmtp.xml | 9 +++++++ 16 files changed, 101 insertions(+), 24 deletions(-) diff --git a/docs/modules/servers/partials/configure/smtp.adoc b/docs/modules/servers/partials/configure/smtp.adoc index 788f205b7bf..f6d826a2f82 100644 --- a/docs/modules/servers/partials/configure/smtp.adoc +++ b/docs/modules/servers/partials/configure/smtp.adoc @@ -99,6 +99,16 @@ channels. | This is an optional tag, defaults to true. If false, AUTH PLAIN and AUTH LOGIN will not be exposed. This setting can be used to enforce strong authentication mechanisms. +| auth.required +| Authentication is required to send emails. Adapted for submission ports. + +Note that if false (legacy value and default for backward compatibility) then unauthenticated senders are allowed but +limited by sender verification (prevent spoofing) and relaying limits (must be authenticated to relay). + +We encourage setting this value to true on submission ports (465 + 587). + +Please note that `authorizedAddresses` are considered authenticated. + | auth.oidc.oidcConfigurationURL | Provide OIDC url address for information to user. Only configure this when you want to authenticate SMTP server using a OIDC provider. @@ -165,6 +175,8 @@ Backward compatibility is provided and thus the following values are supported: - `true`: act as `strict` - `false`: act as `disabled` +Please note that this parameter only intend to prevent spoofing, and still allow unauthenticated remote users (that do not use local identity) to send email to local users. + | maxmessagesize | This is an optional tag with a non-negative integer body. It specifies the maximum size, in kbytes, of any message that will be transmitted by this SMTP server. It is a service-wide, as opposed to diff --git a/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/LMTPConfigurationImpl.java b/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/LMTPConfigurationImpl.java index 4f874e011a1..c81959b0679 100644 --- a/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/LMTPConfigurationImpl.java +++ b/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/LMTPConfigurationImpl.java @@ -31,8 +31,9 @@ public LMTPConfigurationImpl() { } @Override - public SenderVerificationMode verifyIdentity() { - return SenderVerificationMode.DISABLED; + public SenderVerificationConfiguration senderVerificationConfiguration() { + boolean allowUnauthenticatedSender = true; + return new SenderVerificationConfiguration(SenderVerificationMode.DISABLED, allowUnauthenticatedSender); } @Override diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPConfiguration.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPConfiguration.java index 10bffd7fea5..a0eb940633e 100644 --- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPConfiguration.java +++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPConfiguration.java @@ -37,12 +37,15 @@ * */ public interface SMTPConfiguration extends ProtocolConfiguration { + record SenderVerificationConfiguration(SenderVerificationMode mode, boolean allowUnauthenticatedSender) { + + } + enum SenderVerificationMode { STRICT, RELAXED, DISABLED; - // TODO unit tests public static SenderVerificationMode parse(String value) { return switch (value.toLowerCase(Locale.US).trim()) { case "true", "strict" -> STRICT; @@ -77,7 +80,7 @@ public static SenderVerificationMode parse(String value) { */ boolean isAuthAnnounced(String remoteIP, boolean tlsStarted); - SenderVerificationMode verifyIdentity(); + SenderVerificationConfiguration senderVerificationConfiguration(); /** * Returns whether the remote server needs to send a HELO/EHLO diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPConfigurationImpl.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPConfigurationImpl.java index 8da9de699d9..3890210d72c 100644 --- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPConfigurationImpl.java +++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPConfigurationImpl.java @@ -39,8 +39,9 @@ public SMTPConfigurationImpl() { } @Override - public SenderVerificationMode verifyIdentity() { - return SenderVerificationMode.STRICT; + public SenderVerificationConfiguration senderVerificationConfiguration() { + boolean allowUnauthenticatedSender = true; + return new SenderVerificationConfiguration(SenderVerificationMode.STRICT, allowUnauthenticatedSender); } @Override diff --git a/server/apps/distributed-app/sample-configuration/smtpserver.xml b/server/apps/distributed-app/sample-configuration/smtpserver.xml index 11175466465..41f66dc3180 100644 --- a/server/apps/distributed-app/sample-configuration/smtpserver.xml +++ b/server/apps/distributed-app/sample-configuration/smtpserver.xml @@ -89,6 +89,7 @@ forUnauthorizedAddresses true true + true