Skip to content

Commit

Permalink
Merge pull request #1406 from scireum/mke/SE-13522_mail_auth_config
Browse files Browse the repository at this point in the history
Makes mail authentication on transport configurable
  • Loading branch information
mkeckmkeck authored Apr 15, 2024
2 parents db9b682 + 4413c0b commit 042c8ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/sirius/web/mails/SendMailTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import sirius.kernel.di.std.Part;
import sirius.kernel.di.std.Parts;
import sirius.kernel.health.Exceptions;
import sirius.web.security.UserContext;

import java.io.File;
import java.io.UnsupportedEncodingException;
Expand Down Expand Up @@ -504,7 +505,10 @@ protected PasswordAuthentication getPasswordAuthentication() {
protected Transport getSMTPTransport(Session session, SMTPConfiguration config) {
try {
Transport transport = session.getTransport();
transport.connect(config.getMailHost(), config.getMailUser(), config.getMailPassword());
String password = UserContext.getSettings().get("mail.useTransportAuthentication").asBoolean() ?
config.getMailPassword() :
null;
transport.connect(config.getMailHost(), config.getMailUser(), password);
return transport;
} catch (Exception e) {
throw Exceptions.handle()
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/scope-conf/mail.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ mail {

# Whether E-Mail addresses should be encoded with punycode/IDN for e.g. äöüß in international mails
usePunycode = false

# Whether the mail server requires early authentication
useTransportAuthentication = false
}

0 comments on commit 042c8ee

Please sign in to comment.