From 23cd37a2a76f3656ce2d1dc5e62b463d143230db Mon Sep 17 00:00:00 2001 From: PaulBoon Date: Tue, 5 Sep 2023 10:13:50 +0200 Subject: [PATCH] Use support email in the system email message 'closing' text --- .../edu/harvard/iq/dataverse/MailServiceBean.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java index bc7b34ee8b7..400a8f9e9b1 100644 --- a/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java @@ -42,6 +42,7 @@ import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; +import edu.harvard.iq.dataverse.settings.JvmSettings; import edu.harvard.iq.dataverse.validation.EMailValidator; import org.apache.commons.lang3.StringUtils; @@ -92,11 +93,12 @@ public boolean sendSystemEmail(String to, String subject, String messageText) { public boolean sendSystemEmail(String to, String subject, String messageText, boolean isHtmlContent) { boolean sent = false; - InternetAddress systemAddress = getSystemAddress(); + InternetAddress systemAddress = getSystemAddress(); + InternetAddress supportAddress = getSupportAddress(); String body = messageText - + (isHtmlContent ? BundleUtil.getStringFromBundle("notification.email.closing.html", Arrays.asList(BrandingUtil.getSupportTeamEmailAddress(systemAddress), BrandingUtil.getSupportTeamName(systemAddress))) - : BundleUtil.getStringFromBundle("notification.email.closing", Arrays.asList(BrandingUtil.getSupportTeamEmailAddress(systemAddress), BrandingUtil.getSupportTeamName(systemAddress)))); + + (isHtmlContent ? BundleUtil.getStringFromBundle("notification.email.closing.html", Arrays.asList(BrandingUtil.getSupportTeamEmailAddress(supportAddress), BrandingUtil.getSupportTeamName(supportAddress))) + : BundleUtil.getStringFromBundle("notification.email.closing", Arrays.asList(BrandingUtil.getSupportTeamEmailAddress(supportAddress), BrandingUtil.getSupportTeamName(supportAddress)))); logger.fine("Sending email to " + to + ". Subject: <<<" + subject + ">>>. Body: " + body); try { @@ -146,6 +148,13 @@ public InternetAddress getSystemAddress() { return MailUtil.parseSystemAddress(systemEmail); } + public InternetAddress getSupportAddress() { + String supportEmail = JvmSettings.SUPPORT_EMAIL + .lookupOptional() + .orElse(settingsService.getValueForKey(SettingsServiceBean.Key.SystemEmail)); + return MailUtil.parseSystemAddress(supportEmail); + } + //@Resource(name="mail/notifyMailSession") public void sendMail(String reply, String to, String cc, String subject, String messageText) { try {