From 72cbac1a5655e8331cccf35c7a3eee2af99241c8 Mon Sep 17 00:00:00 2001 From: Bernardus Jansen Date: Thu, 19 May 2016 21:51:14 +0200 Subject: [PATCH] Small changes/fixes Signed-off-by: Bernardus Jansen --- .../player/command/AdvancedSettingsCommand.java | 6 +++--- .../player/controller/MultiController.java | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java b/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java index 5fe712af..f2669608 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java +++ b/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java @@ -42,7 +42,7 @@ public class AdvancedSettingsCommand { private String smtpServer; private String smtpEncryption; - private int smtpPort; + private String smtpPort; private String smtpUser; private String smtpPassword; @@ -150,11 +150,11 @@ public class AdvancedSettingsCommand { this.smtpEncryption = smtpEncryption; } - public int getSMTPPort() { + public String getSMTPPort() { return smtpPort; } - public void setSMTPPort(int smtpPort) { + public void setSMTPPort(String smtpPort) { this.smtpPort = smtpPort; } diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java index a5dac659..0828afa6 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java @@ -137,7 +137,11 @@ public class MultiController extends MultiActionController { return new ModelAndView("recover", "model", map); } + /* + * e-mail user new password via configured SMTP server + */ private boolean emailPassword(String password, String username, String email) { + /* Default to protocol smtp when SMTPEncryption is set to "None" */ String prot = "smtp"; if (settingsService.getSMTPServer() == null || settingsService.getSMTPServer().isEmpty()) { @@ -155,6 +159,7 @@ public class MultiController extends MultiActionController { } props.put("mail." + prot + ".host", settingsService.getSMTPServer()); props.put("mail." + prot + ".port", settingsService.getSMTPPort()); + /* use authentication when SMTPUser is configured */ if (settingsService.getSMTPUser() != null && !settingsService.getSMTPUser().isEmpty()) { props.put("mail." + prot + ".auth", "true"); } @@ -174,13 +179,13 @@ public class MultiController extends MultiActionController { "Your Libresonic server\n" + "libresonic.org"); message.setSentDate(new Date()); - + Transport trans = session.getTransport(prot); try { - if (settingsService.getSMTPUser() != null && !settingsService.getSMTPUser().isEmpty()) { - trans.connect(); - } else { + if (props.get("mail." + prot + ".auth").equals("true")) { trans.connect(settingsService.getSMTPServer(), settingsService.getSMTPUser(), settingsService.getSMTPPassword()); + } else { + trans.connect(); } trans.sendMessage(message, message.getAllRecipients()); } finally {