From ae18aef1ce6a7861cd3c52029ed134bf7f4a07ee Mon Sep 17 00:00:00 2001 From: Miguel Carro Pellicer Date: Mon, 30 Mar 2015 13:03:25 +0200 Subject: [PATCH] SAK-13910 SAK-13910 - Allow hard-coded 'reply-to' address to be overridden --- .../announcement/impl/SiteEmailNotificationAnnc.java | 4 ++-- .../sakaiproject/assignment/impl/BaseAssignmentService.java | 2 +- .../org/sakaiproject/config/bundle/default.sakai.properties | 3 ++- .../content/tool/SiteEmailNotificationDragAndDrop.java | 2 +- .../impl/external/SakaiExternalIntegrationProvider.java | 2 +- .../main/java/org/sakaiproject/util/EmailNotification.java | 3 +-- .../java/org/sakaiproject/util/SiteEmailNotification.java | 2 +- .../mailsender/logic/impl/ExternalLogicImpl.java | 2 +- .../app/messageforums/ui/PrivateMessageManagerImpl.java | 2 +- .../org/sakaiproject/poll/logic/impl/ExternalLogicImpl.java | 2 +- .../portal/chat/entity/PCServiceEntityProvider.java | 2 +- .../java/org/sakaiproject/portal/util/ErrorReporter.java | 2 +- .../org/sakaiproject/profile2/logic/SakaiProxyImpl.java | 2 +- .../accountvalidator/logic/impl/ValidationLogicImpl.java | 6 +++--- .../ui/listener/author/PublishAssessmentListener.java | 2 +- .../tool/assessment/util/SamigoEmailService.java | 2 +- .../sakaiproject/signup/logic/messages/SignupEmailBase.java | 2 +- .../sitemanage/impl/ETSUserNotificationProviderImpl.java | 2 +- .../sitemanage/impl/UserNotificationProviderImpl.java | 2 +- 19 files changed, 23 insertions(+), 23 deletions(-) diff --git a/announcement/announcement-impl/impl/src/java/org/sakaiproject/announcement/impl/SiteEmailNotificationAnnc.java b/announcement/announcement-impl/impl/src/java/org/sakaiproject/announcement/impl/SiteEmailNotificationAnnc.java index fa23eb0e40ce..600e31387400 100644 --- a/announcement/announcement-impl/impl/src/java/org/sakaiproject/announcement/impl/SiteEmailNotificationAnnc.java +++ b/announcement/announcement-impl/impl/src/java/org/sakaiproject/announcement/impl/SiteEmailNotificationAnnc.java @@ -334,7 +334,7 @@ protected String getFromAddress(Event event) catch(Exception ignore) {} - String userEmail = "no-reply@" + ServerConfigurationService.getServerName(); + String userEmail = ServerConfigurationService.getString("setup.request","no-reply@" + ServerConfigurationService.getServerName()); String userDisplay = ServerConfigurationService.getString("ui.service", "Sakai"); //String no_reply = "From: \"" + userDisplay + "\" <" + userEmail + ">"; //String no_reply_withTitle = "From: \"" + title + "\" <" + userEmail + ">"; @@ -371,7 +371,7 @@ protected String getFromAddress(Event event) } // some fallback positions - if (userEmail == null) userEmail = "no-reply@" + ServerConfigurationService.getServerName(); + if (userEmail == null) userEmail = ServerConfigurationService.getString("setup.request","no-reply@" + ServerConfigurationService.getServerName()); if (userDisplay == null) userDisplay = ServerConfigurationService.getString("ui.service", "Sakai"); from="From: \"" + userDisplay + "\" <" + userEmail + ">"; } diff --git a/assignment/assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/BaseAssignmentService.java b/assignment/assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/BaseAssignmentService.java index a6246154251a..15b008f615ee 100644 --- a/assignment/assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/BaseAssignmentService.java +++ b/assignment/assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/BaseAssignmentService.java @@ -2691,7 +2691,7 @@ else if ("releasegrade".equals(submissionOrReleaseGrade)) protected String getFrom() { - return "From: " + "\"" + m_serverConfigurationService.getString("ui.service", "Sakai") + "\""; + return "From: " + "\"" + m_serverConfigurationService.getString("ui.service", "Sakai") + "\" <"+ m_serverConfigurationService.getString("setup.request","no-reply@"+ m_serverConfigurationService.getServerName()) + ">"; } private final String MULTIPART_BOUNDARY = "======sakai-multi-part-boundary======"; diff --git a/config/configuration/bundles/src/bundle/org/sakaiproject/config/bundle/default.sakai.properties b/config/configuration/bundles/src/bundle/org/sakaiproject/config/bundle/default.sakai.properties index a72c47612489..52784d3e70f9 100644 --- a/config/configuration/bundles/src/bundle/org/sakaiproject/config/bundle/default.sakai.properties +++ b/config/configuration/bundles/src/bundle/org/sakaiproject/config/bundle/default.sakai.properties @@ -1284,7 +1284,8 @@ # DEFAULT: none (null) # portal.error.email= -# Email address used as the "from" address for any email sent by Worksite Setup tool or Site Info tool. +# Email address used as the "from" address for any email sent by any Sakai tool. +# If the value is not set, the tools will use no-reply@${serverName} or postmaster@${serverName} # DEFAULT: none (null) # setup.request= diff --git a/content/content-tool/tool/src/java/org/sakaiproject/content/tool/SiteEmailNotificationDragAndDrop.java b/content/content-tool/tool/src/java/org/sakaiproject/content/tool/SiteEmailNotificationDragAndDrop.java index bf7a8dd94504..4ee78c70ea61 100644 --- a/content/content-tool/tool/src/java/org/sakaiproject/content/tool/SiteEmailNotificationDragAndDrop.java +++ b/content/content-tool/tool/src/java/org/sakaiproject/content/tool/SiteEmailNotificationDragAndDrop.java @@ -143,7 +143,7 @@ protected String getSubject(Event event) } protected String getFromAddress(Event event) { - String userEmail = "no-reply@" + serverConfigurationService.getServerName(); + String userEmail = serverConfigurationService.getString("setup.request","no-reply@" + serverConfigurationService.getServerName()); String userDisplay = serverConfigurationService.getString("ui.service", "Sakai"); String no_reply = "From: \"" + userDisplay + "\" <" + userEmail + ">"; String from = getFrom(event); diff --git a/entitybroker/impl/src/java/org/sakaiproject/entitybroker/impl/external/SakaiExternalIntegrationProvider.java b/entitybroker/impl/src/java/org/sakaiproject/entitybroker/impl/external/SakaiExternalIntegrationProvider.java index 67a5b51dc5f4..df32cb872073 100644 --- a/entitybroker/impl/src/java/org/sakaiproject/entitybroker/impl/external/SakaiExternalIntegrationProvider.java +++ b/entitybroker/impl/src/java/org/sakaiproject/entitybroker/impl/external/SakaiExternalIntegrationProvider.java @@ -228,7 +228,7 @@ public String handleEntityError(HttpServletRequest req, Throwable error) { serverConfigurationService.getString("portal.error.email")); if (emailAddr != null && !"".equals(emailAddr)) { - String from = "\""; + String from = "\" <"+ serverConfigurationService.getString("setup.request","no-reply@" + serverConfigurationService.getServerName()) + ">"; if (emailService != null) { emailService.send(from, emailAddr, subject, body + "\n" + stacktrace, emailAddr, null, null); } else { diff --git a/kernel/kernel-util/src/main/java/org/sakaiproject/util/EmailNotification.java b/kernel/kernel-util/src/main/java/org/sakaiproject/util/EmailNotification.java index 8f64e20f14c4..7ae9a7595434 100644 --- a/kernel/kernel-util/src/main/java/org/sakaiproject/util/EmailNotification.java +++ b/kernel/kernel-util/src/main/java/org/sakaiproject/util/EmailNotification.java @@ -762,8 +762,7 @@ protected String getFrom(Event event) */ protected String getFromService() { - return "\"" + ServerConfigurationService.getString("ui.service", "Sakai") + "\""; + return "\"" + ServerConfigurationService.getString("ui.service", "Sakai") + "\" <"+ ServerConfigurationService.getString("setup.request","no-reply@"+ ServerConfigurationService.getServerName()) + ">"; } /** diff --git a/kernel/kernel-util/src/main/java/org/sakaiproject/util/SiteEmailNotification.java b/kernel/kernel-util/src/main/java/org/sakaiproject/util/SiteEmailNotification.java index a6219af5cba8..5ef31f5dfe78 100644 --- a/kernel/kernel-util/src/main/java/org/sakaiproject/util/SiteEmailNotification.java +++ b/kernel/kernel-util/src/main/java/org/sakaiproject/util/SiteEmailNotification.java @@ -204,7 +204,7 @@ protected String getToSiteNoReply(Event event) { } - return "\"" + title + "\""; + return "\"" + title + "\" <"+ ServerConfigurationService.getString("setup.request","no-reply@" + ServerConfigurationService.getServerName()) + ">"; } /** diff --git a/mailsender/impl/src/java/org/sakaiproject/mailsender/logic/impl/ExternalLogicImpl.java b/mailsender/impl/src/java/org/sakaiproject/mailsender/logic/impl/ExternalLogicImpl.java index 3e3c7f82e172..27a5d4547a85 100644 --- a/mailsender/impl/src/java/org/sakaiproject/mailsender/logic/impl/ExternalLogicImpl.java +++ b/mailsender/impl/src/java/org/sakaiproject/mailsender/logic/impl/ExternalLogicImpl.java @@ -365,7 +365,7 @@ public List sendEmail(ConfigEntry config, String fromEmail, String fromN if (ConfigEntry.ReplyTo.no_reply_to.name().equals(config.getReplyTo())) { replyToName = getCurrentSiteTitle(); - replyToEmail = "no-reply@" + configService.getServerName(); + replyToEmail = configService.getString("setup.request","no-reply@" + configService.getServerName()); } else { diff --git a/msgcntr/messageforums-component-impl/src/java/org/sakaiproject/component/app/messageforums/ui/PrivateMessageManagerImpl.java b/msgcntr/messageforums-component-impl/src/java/org/sakaiproject/component/app/messageforums/ui/PrivateMessageManagerImpl.java index cbd82690455f..7435aac6b859 100644 --- a/msgcntr/messageforums-component-impl/src/java/org/sakaiproject/component/app/messageforums/ui/PrivateMessageManagerImpl.java +++ b/msgcntr/messageforums-component-impl/src/java/org/sakaiproject/component/app/messageforums/ui/PrivateMessageManagerImpl.java @@ -1138,7 +1138,7 @@ public void sendPrivateMessage(PrivateMessage message, Map recipi /** determines if default in sakai.properties is set, if not will make a reasonable default */ - String defaultEmail = "postmaster@" + ServerConfigurationService.getServerName(); + String defaultEmail = ServerConfigurationService.getString("setup.request","postmaster@" + ServerConfigurationService.getServerName()); String systemEmail = ServerConfigurationService.getString("msgcntr.notification.from.address", defaultEmail); if (!ServerConfigurationService.getBoolean("msgcntr.notification.user.real.from", false)) { diff --git a/polls/impl/src/java/org/sakaiproject/poll/logic/impl/ExternalLogicImpl.java b/polls/impl/src/java/org/sakaiproject/poll/logic/impl/ExternalLogicImpl.java index 2dbad726ae94..217e56b3a4a0 100644 --- a/polls/impl/src/java/org/sakaiproject/poll/logic/impl/ExternalLogicImpl.java +++ b/polls/impl/src/java/org/sakaiproject/poll/logic/impl/ExternalLogicImpl.java @@ -461,7 +461,7 @@ else if (pollQuestion == null) Map replacementValues = new HashMap(); String from = (fromEmailAddress == null || fromEmailAddress.equals("")) ? - serverConfigurationService.getString("smtpFrom@org.sakaiproject.email.api.EmailService") : fromEmailAddress; + serverConfigurationService.getString("setup.request", "no-reply@" + serverConfigurationService.getServerName()) : fromEmailAddress; for (String userEid : userEids) { User user = null; diff --git a/portal/portal-chat/tool/src/java/org/sakaiproject/portal/chat/entity/PCServiceEntityProvider.java b/portal/portal-chat/tool/src/java/org/sakaiproject/portal/chat/entity/PCServiceEntityProvider.java index fb07417bd408..1aab0c1c4233 100644 --- a/portal/portal-chat/tool/src/java/org/sakaiproject/portal/chat/entity/PCServiceEntityProvider.java +++ b/portal/portal-chat/tool/src/java/org/sakaiproject/portal/chat/entity/PCServiceEntityProvider.java @@ -651,7 +651,7 @@ public synchronized void run() { final List additionalHeaders = new ArrayList(); additionalHeaders.add("Content-Type: text/plain; charset=ISO-8859-1"); - final String emailFromAddress = "\"" + service + "\" "; + final String emailFromAddress = "\"" + service + "\" <" + serverConfigurationService.getString("setup.request","no-reply@" + serverName) + ">"; emailService.send(emailFromAddress, email, subject, message, email, null, additionalHeaders); } catch (Exception e) { logger.error("sendEmail() failed for email: " + email,e); diff --git a/portal/portal-util/util/src/java/org/sakaiproject/portal/util/ErrorReporter.java b/portal/portal-util/util/src/java/org/sakaiproject/portal/util/ErrorReporter.java index c4e825f1172e..fe5fa093f61d 100644 --- a/portal/portal-util/util/src/java/org/sakaiproject/portal/util/ErrorReporter.java +++ b/portal/portal-util/util/src/java/org/sakaiproject/portal/util/ErrorReporter.java @@ -339,7 +339,7 @@ protected void logAndMail(String bugId, String usageSessionId, String userId, St String from = "\"" + ServerConfigurationService.getString("ui.service", "Sakai") - + "\""; + + "\" <"+ServerConfigurationService.getString("setup.request","no-reply@" + ServerConfigurationService.getServerName()) + ">"; String problemDisplay = ""; diff --git a/profile2/impl/src/java/org/sakaiproject/profile2/logic/SakaiProxyImpl.java b/profile2/impl/src/java/org/sakaiproject/profile2/logic/SakaiProxyImpl.java index af72a02021db..7e032d90299d 100644 --- a/profile2/impl/src/java/org/sakaiproject/profile2/logic/SakaiProxyImpl.java +++ b/profile2/impl/src/java/org/sakaiproject/profile2/logic/SakaiProxyImpl.java @@ -720,7 +720,7 @@ private String getFrom(){ sb.append("From: "); sb.append(getServiceName()); sb.append(" <"); - sb.append(serverConfigurationService.getString("smtpFrom@org.sakaiproject.email.api.EmailService","no-reply@"+getServerName())); + sb.append(serverConfigurationService.getString("setup.request", "no-reply@" + getServerName())); sb.append(">"); return sb.toString(); diff --git a/reset-pass/account-validator-impl/src/java/org/sakaiproject/accountvalidator/logic/impl/ValidationLogicImpl.java b/reset-pass/account-validator-impl/src/java/org/sakaiproject/accountvalidator/logic/impl/ValidationLogicImpl.java index 9fa00dee4f6a..46373f15d099 100644 --- a/reset-pass/account-validator-impl/src/java/org/sakaiproject/accountvalidator/logic/impl/ValidationLogicImpl.java +++ b/reset-pass/account-validator-impl/src/java/org/sakaiproject/accountvalidator/logic/impl/ValidationLogicImpl.java @@ -466,13 +466,13 @@ public ValidationAccount createValidationAccount(String userRef, replacementValues.put("memberSites", sb.toString()); replacementValues.put("displayName", userDisplayName); replacementValues.put("userEid", userEid); - replacementValues.put("support.email", serverConfigurationService.getString("support.email")); + replacementValues.put("support.email", serverConfigurationService.getString("setup.request", "no-reply@"+serverConfigurationService.getServerName())); replacementValues.put("institution", serverConfigurationService.getString("ui.institution")); String templateKey = getTemplateKey(accountStatus); - emailTemplateService.sendRenderedMessages(templateKey , userReferences, replacementValues, serverConfigurationService.getString("support.email"), serverConfigurationService.getString("support.email")); + emailTemplateService.sendRenderedMessages(templateKey , userReferences, replacementValues, serverConfigurationService.getString("setup.request", "no-reply@"+serverConfigurationService.getServerName()), serverConfigurationService.getString("setup.request", "no-reply@"+serverConfigurationService.getServerName())); v.setValidationSent(new Date()); v.setStatus(ValidationAccount.STATUS_SENT); @@ -755,7 +755,7 @@ public void resendValidation(String token) { String templateKey = getTemplateKey(account.getAccountStatus()); - emailTemplateService.sendRenderedMessages(templateKey , userReferences, replacementValues, serverConfigurationService.getString("support.email"), serverConfigurationService.getString("support.email")); + emailTemplateService.sendRenderedMessages(templateKey , userReferences, replacementValues, serverConfigurationService.getString("setup.request", "no-reply@"+serverConfigurationService.getServerName()), serverConfigurationService.getString("setup.request", "no-reply@"+serverConfigurationService.getServerName())); } diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java index 236127d4e19a..451d8490f901 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java @@ -336,7 +336,7 @@ public void sendNotification(PublishedAssessmentFacade pub, PublishedAssessmentS } - String noReplyEmaillAddress = "no-reply@" + ServerConfigurationService.getServerName(); + String noReplyEmaillAddress = ServerConfigurationService.getString("setup.request","no-reply@" + ServerConfigurationService.getServerName()); InternetAddress[] noReply = new InternetAddress[1]; try { noReply[0] = new InternetAddress(noReplyEmaillAddress); diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/util/SamigoEmailService.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/util/SamigoEmailService.java index db992e90987e..a101da1e5b32 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/util/SamigoEmailService.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/util/SamigoEmailService.java @@ -266,7 +266,7 @@ public String sendMail() { //msg.addHeaderLine("Subject: " + subject); msg.setSubject(subject, "UTF-8"); - String noReplyEmaillAddress = "no-reply@" + ServerConfigurationService.getServerName(); + String noReplyEmaillAddress = ServerConfigurationService.getString("setup.request","no-reply@" + ServerConfigurationService.getServerName()); msg.addHeaderLine("To: " + noReplyEmaillAddress); msg.setText(message, "UTF-8"); msg.addHeaderLine("Content-Type: text/html"); diff --git a/signup/impl/src/java/org/sakaiproject/signup/logic/messages/SignupEmailBase.java b/signup/impl/src/java/org/sakaiproject/signup/logic/messages/SignupEmailBase.java index 98162f15876a..346e259c8ed0 100644 --- a/signup/impl/src/java/org/sakaiproject/signup/logic/messages/SignupEmailBase.java +++ b/signup/impl/src/java/org/sakaiproject/signup/logic/messages/SignupEmailBase.java @@ -257,7 +257,7 @@ else if (BIWEEKLY.equals(meeting.getRepeatType())) } protected String getServerFromAddress() { - return getServiceName() +" <" + getSakaiFacade().getServerConfigurationService().getString("smtpFrom@org.sakaiproject.email.api.EmailService",rb.getString("noReply@") + getSakaiFacade().getServerConfigurationService().getServerName())+ ">"; + return getServiceName() +" <" + getSakaiFacade().getServerConfigurationService().getString("setup.request",rb.getString("no-reply@") + getSakaiFacade().getServerConfigurationService().getServerName())+ ">"; } protected boolean userIsAttendingTimeslot(User user, SignupTimeslot timeslot) { diff --git a/site-manage/site-manage-impl/impl/src/java/org/sakaiproject/sitemanage/impl/ETSUserNotificationProviderImpl.java b/site-manage/site-manage-impl/impl/src/java/org/sakaiproject/sitemanage/impl/ETSUserNotificationProviderImpl.java index adb30f448c4f..c79a3206ee06 100644 --- a/site-manage/site-manage-impl/impl/src/java/org/sakaiproject/sitemanage/impl/ETSUserNotificationProviderImpl.java +++ b/site-manage/site-manage-impl/impl/src/java/org/sakaiproject/sitemanage/impl/ETSUserNotificationProviderImpl.java @@ -390,7 +390,7 @@ public void notifySiteCreation(Site site, List notifySites, boolean courseSite, from = requestEmail; to = currentUserEmail; headerTo = currentUserEmail; - replyTo = "no-reply@" + serverConfigurationService.getServerName(); + replyTo = serverConfigurationService.getString("setup.request","no-reply@" + serverConfigurationService.getServerName()); emailTemplateServiceSend(NOTIFY_SITE_CREATION_CONFIRMATION, (new ResourceLoader()).getLocale(), currentUser, from, to, headerTo, replyTo, replacementValues); } diff --git a/site-manage/site-manage-impl/impl/src/java/org/sakaiproject/sitemanage/impl/UserNotificationProviderImpl.java b/site-manage/site-manage-impl/impl/src/java/org/sakaiproject/sitemanage/impl/UserNotificationProviderImpl.java index 51b475444219..d7936dc153f4 100644 --- a/site-manage/site-manage-impl/impl/src/java/org/sakaiproject/sitemanage/impl/UserNotificationProviderImpl.java +++ b/site-manage/site-manage-impl/impl/src/java/org/sakaiproject/sitemanage/impl/UserNotificationProviderImpl.java @@ -272,7 +272,7 @@ public void notifySiteCreation(Site site, List notifySites, boolean courseSite, from = requestEmail; to = currentUserEmail; headerTo = currentUserEmail; - replyTo = "no-reply@" + serverConfigurationService.getServerName(); + replyTo = serverConfigurationService.getString("setup.request","no-reply@" + serverConfigurationService.getServerName()); String content = rb.getFormattedMessage("java.siteCreation.confirmation", new Object[]{title, serverConfigurationService.getServerName()}); content += "\n\n" + buf.toString(); emailService.send(from, to, message_subject, content, headerTo, replyTo, null);