Skip to content

Commit

Permalink
SAK-13910
Browse files Browse the repository at this point in the history
SAK-13910  - Allow hard-coded 'reply-to' address to be overridden
  • Loading branch information
Miguel Carro Pellicer committed Mar 30, 2015
1 parent 139006a commit ae18aef
Show file tree
Hide file tree
Showing 19 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ">";
Expand Down Expand Up @@ -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 + ">";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2691,7 +2691,7 @@ else if ("releasegrade".equals(submissionOrReleaseGrade))

protected String getFrom()
{
return "From: " + "\"" + m_serverConfigurationService.getString("ui.service", "Sakai") + "\"<no-reply@"+ m_serverConfigurationService.getServerName() + ">";
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======";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public String handleEntityError(HttpServletRequest req, Throwable error) {
serverConfigurationService.getString("portal.error.email"));

if (emailAddr != null && !"".equals(emailAddr)) {
String from = "\"<no-reply@" + serverConfigurationService.getServerName() + ">";
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,7 @@ protected String getFrom(Event event)
*/
protected String getFromService()
{
return "\"" + ServerConfigurationService.getString("ui.service", "Sakai") + "\"<no-reply@"
+ ServerConfigurationService.getServerName() + ">";
return "\"" + ServerConfigurationService.getString("ui.service", "Sakai") + "\" <"+ ServerConfigurationService.getString("setup.request","no-reply@"+ ServerConfigurationService.getServerName()) + ">";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ protected String getToSiteNoReply(Event event)
{
}

return "\"" + title + "\"<no-reply@" + ServerConfigurationService.getServerName() + ">";
return "\"" + title + "\" <"+ ServerConfigurationService.getString("setup.request","no-reply@" + ServerConfigurationService.getServerName()) + ">";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public List<String> 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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ public void sendPrivateMessage(PrivateMessage message, Map<User, Boolean> 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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ else if (pollQuestion == null)
Map<String, String> replacementValues = new HashMap<String, String>();

String from = (fromEmailAddress == null || fromEmailAddress.equals("")) ?
serverConfigurationService.getString("[email protected]") : fromEmailAddress;
serverConfigurationService.getString("setup.request", "no-reply@" + serverConfigurationService.getServerName()) : fromEmailAddress;

for (String userEid : userEids) {
User user = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public synchronized void run() {
final List<String> additionalHeaders = new ArrayList<String>();
additionalHeaders.add("Content-Type: text/plain; charset=ISO-8859-1");

final String emailFromAddress = "\"" + service + "\" <no-reply@" + serverName + ">";
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ protected void logAndMail(String bugId, String usageSessionId, String userId, St

String from = "\""
+ ServerConfigurationService.getString("ui.service", "Sakai")
+ "\"<no-reply@" + ServerConfigurationService.getServerName() + ">";
+ "\" <"+ServerConfigurationService.getString("setup.request","no-reply@" + ServerConfigurationService.getServerName()) + ">";

String problemDisplay = "";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ private String getFrom(){
sb.append("From: ");
sb.append(getServiceName());
sb.append(" <");
sb.append(serverConfigurationService.getString("[email protected]","no-reply@"+getServerName()));
sb.append(serverConfigurationService.getString("setup.request", "no-reply@" + getServerName()));
sb.append(">");

return sb.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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()));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ else if (BIWEEKLY.equals(meeting.getRepeatType()))
}

protected String getServerFromAddress() {
return getServiceName() +" <" + getSakaiFacade().getServerConfigurationService().getString("[email protected]",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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ae18aef

Please sign in to comment.