[New] SmtpMailer now understands whitelists for override

This commit is contained in:
Robert von Burg 2017-03-16 13:45:30 +01:00
parent 58248058e5
commit a618fff095
1 changed files with 8 additions and 5 deletions

View File

@ -97,11 +97,11 @@ public class SmtpMailer {
String fromName = properties.getProperty("fromName", null); String fromName = properties.getProperty("fromName", null);
this.from = new InternetAddress(fromAddr, fromName); this.from = new InternetAddress(fromAddr, fromName);
if (properties.containsKey("overrideRecipients")) { if (!properties.containsKey("overrideRecipients")) {
this.overrideRecipients = null;
} else {
String addr = properties.getProperty("overrideRecipients", null); String addr = properties.getProperty("overrideRecipients", null);
this.overrideRecipients = InternetAddress.parse(addr); this.overrideRecipients = InternetAddress.parse(addr);
} else {
this.overrideRecipients = null;
} }
if (!properties.containsKey("recipientWhitelist")) { if (!properties.containsKey("recipientWhitelist")) {
@ -179,8 +179,11 @@ public class SmtpMailer {
} }
if (!allowList.isEmpty()) { if (!allowList.isEmpty()) {
send(subject, text, parseAddress(recipients)); InternetAddress[] arr = new InternetAddress[allowList.size()];
logger.info(MessageFormat.format("Sent E-mail to {0}: {1}", recipients, subject)); allowList.toArray(arr);
send(subject, text, arr);
logger.info(
MessageFormat.format("Sent E-mail to white list recipient {0}: {1}", recipients, subject));
} }
if (needsOverrides) { if (needsOverrides) {