diff --git a/app/models/NotificationMail.java b/app/models/NotificationMail.java index 352525593..30db14849 100644 --- a/app/models/NotificationMail.java +++ b/app/models/NotificationMail.java @@ -24,7 +24,6 @@ import models.enumeration.UserState; import models.resource.Resource; import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.mail.HtmlEmail; import org.joda.time.DateTime; import org.jsoup.Jsoup; @@ -53,6 +52,7 @@ @Entity public class NotificationMail extends Model { private static final long serialVersionUID = 1L; + static boolean hideAddress = true; @Id public Long id; @@ -64,6 +64,9 @@ public class NotificationMail extends Model { NotificationMail.class); public static void onStart() { + hideAddress = play.Configuration.root().getBoolean( + "application.notification.bymail.hideAddress", true); + if (notificationEnabled()) { NotificationMail.startSchedule(); } @@ -179,11 +182,23 @@ private static void sendNotification(NotificationEvent event) { final HtmlEmail email = new HtmlEmail(); try { - email.setFrom(Config.getEmailFromSmtp(), event.getSender().name); - email.addTo(Config.getEmailFromSmtp(), utils.Config.getSiteName()); + if (hideAddress) { + email.setFrom(Config.getEmailFromSmtp(), event.getSender().name); + email.addTo(Config.getEmailFromSmtp(), utils.Config.getSiteName()); + } else { + email.setFrom(event.getSender().email, event.getSender().name); + } for (User receiver : usersByLang.get(langCode)) { - email.addBcc(receiver.email, receiver.name); + if (hideAddress) { + email.addBcc(receiver.email, receiver.name); + } else { + email.addTo(receiver.email, receiver.name); + } + } + + if (email.getToAddresses().isEmpty()) { + continue; } Lang lang = Lang.apply(langCode); diff --git a/conf/application.conf.default b/conf/application.conf.default index bf961717b..f0d7897be 100644 --- a/conf/application.conf.default +++ b/conf/application.conf.default @@ -129,6 +129,8 @@ smtp.archive.size = 5 application.notification.bymail.interval = 60s # Sending a notification mail delays this seconds. application.notification.bymail.delay = 180s +# Hide recipients of notification email by using bcc. (default: true) +application.notification.bymail.hideAddress = true # A new event notification can be merged if possible with previous one which is # not older than this seconds. application.notification.draft-time = 30s