Skip to content

Commit

Permalink
Merge pull request #176 from PaulBoon/DD-1058-FixSupportContactInSyst…
Browse files Browse the repository at this point in the history
…emEmail

DD-1058 Use support email in the system email message 'closing' text
  • Loading branch information
janvanmansum authored Sep 26, 2023
2 parents bdee5fc + 23cd37a commit 72840e2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 72840e2

Please sign in to comment.