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