diff --git a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/RegisterServlet.java b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/RegisterServlet.java index 5580b4f78c..f626476e66 100644 --- a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/RegisterServlet.java +++ b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/RegisterServlet.java @@ -39,34 +39,27 @@ */ package org.dspace.app.webui.servlet; -import java.io.IOException; -import java.sql.SQLException; - -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.internet.AddressException; -import javax.mail.internet.InternetAddress; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - +import com.sun.mail.smtp.SMTPAddressFailedException; import org.apache.log4j.Logger; -import org.dspace.app.webui.util.Authenticate; import org.dspace.app.webui.util.JSPManager; import org.dspace.app.webui.util.UIUtil; import org.dspace.authenticate.AuthenticationManager; import org.dspace.authorize.AuthorizeException; -import org.dspace.core.ConfigurationManager; -import org.dspace.core.Context; -import org.dspace.core.LogManager; +import org.dspace.core.*; import org.dspace.eperson.AccountManager; import org.dspace.eperson.EPerson; -import com.sun.mail.smtp.SMTPAddressFailedException; - +import javax.mail.MessagingException; +import javax.mail.internet.AddressException; +import javax.naming.NamingException; +import javax.naming.directory.DirContext; +import javax.naming.directory.InitialDirContext; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.sql.SQLException; import java.util.Hashtable; -import javax.naming.*; -import javax.naming.directory.*; /** * Servlet for handling user registration and forgotten passwords. @@ -534,6 +527,43 @@ public class RegisterServlet extends DSpaceServlet eperson.update(); request.setAttribute("eperson", eperson); + + + // Notify of new user registration + String notifyRecipient = ConfigurationManager.getProperty("registration.notify"); + if (notifyRecipient == null) { + notifyRecipient = ""; + } + notifyRecipient = notifyRecipient.trim(); + + if(!notifyRecipient.equals("")) + { + try + { + Email adminEmail = ConfigurationManager.getEmail(I18nUtil.getEmailFilename(context.getCurrentLocale(), "registration_notify")); + adminEmail.addRecipient(notifyRecipient); + + adminEmail.addArgument(eperson.getFirstName() + " " + eperson.getLastName()); // Name + adminEmail.addArgument(eperson.getEmail()); // Email + + adminEmail.setReplyTo(eperson.getEmail()); + + adminEmail.send(); + + log.info(LogManager.getHeader(context, "registerion_alert", "user=" + + eperson.getEmail())); + } + catch (MessagingException me) + { + log.warn(LogManager.getHeader(context, + "error_emailing_administrator", ""), me); + + JSPManager.showInternalError(request, response); + } + } + + + JSPManager.showJSP(request, response, "/register/registered.jsp"); context.complete(); } diff --git a/dspace/CHANGES b/dspace/CHANGES index 16e118176d..5fedf4dbd5 100644 --- a/dspace/CHANGES +++ b/dspace/CHANGES @@ -66,6 +66,7 @@ SF Patch 1794700 Bug fix for stat-monthly and stat-report-monthly (Chris yates) - SF Patch #1724330 Removes "null" being displayed in community-home.jsp +- SF Patch #1763535 Alert DSpace administrator of new user registration (Robert Tansley / Stuart Lewis) - SF Patch #1587225 Google and html sitemap generator diff --git a/dspace/config/dspace.cfg b/dspace/config/dspace.cfg index 0b7fae275c..44380b2e9c 100644 --- a/dspace/config/dspace.cfg +++ b/dspace/config/dspace.cfg @@ -79,6 +79,9 @@ mail.admin = dspace-help@myu.edu # Recipient for server errors and alerts # alert.recipient = email-address-here +# Recipient for new user registration emails +# registration.notify.new = email-address-here + ##### File Storage ###### diff --git a/dspace/config/emails/registration_notify b/dspace/config/emails/registration_notify new file mode 100644 index 0000000000..3950230b6f --- /dev/null +++ b/dspace/config/emails/registration_notify @@ -0,0 +1,15 @@ +# Registration notification email +# +# Parameters: {0} Name: +# {1} Email: +# {2} Registration Date: +# +# See org.dspace.core.Email for information on the format of this file. +# +Subject: DSpace: Registration Notification + +A new user has registered on the system: + +Name: {0} +Email: {1} +Date: {2}