Sending email to portal administrator when new user is registered

Version 4

    WARNING: This feature is now documented in GateIn reference guide https://docs.jboss.org/author/display/GTNPORTAL35/Send+mail+to+administrator+when+new+user+is+registered where are latest informations. This wiki page is no longer maintained and may have outdated info.

     

    It maybe useful for portal administrator to be notified when some new user register himself into portal. Especially if portal provides public registration page. So if you are administrator of GateIn portal or EPP5.*, then this article is for you.

     

    Please note that this feature is not provided in GateIn or EPP 5.* out of the box. So if you want this feature, you will need to download and install portal extension (something like plugin) and configure it for correct work in your portal.

     

    You will need to do these steps:

     

    1) Checkout sources of portal registration extension and build it - You can checkout project sources from SVN and build project with maven. This project contains some necessary subprojects with classes and configurations needed for functionality of sending mails after registration of new user.

    SVN location of project is http://anonsvn.jboss.org/repos/qa/portal/registration-extension/ . After checkout, you can build project by command mvn clean install (Recommended version of Maven is 2.2.1 or later)

     

    2) Deploy extension EAR - After successful build, you will need to copy EAR directory to your GateIn portal. So copy directory registration-extension-ear/target/registration-extension.ear into your portal into $GATEIN_HOME/server/default/deploy directory.

     

    3) Change webui.configuration parameter in RegisterPortlet - You will need to do one necessary change in configuration of your GateIn portal. You need to go into WAR archiv $GATEIN_HOME/server/default/deploy/gatein.ear/exoadmin.war and open file WEB-INF/portlet.xml inside this archiv. Here you will need to find configuration of RegistrationPortlet and change value of webui.configuration parameter . So you will need to change (or comment) value /WEB-INF/conf/portlet/exoadmin/RegisterPortlet/webui/configuration.xml and replace it with value classpath:portlet/exoadmin/RegisterPortlet/webui/configuration.xml . So your configuration needs to look like this:

     

       <portlet>
          <description xml:lang="EN">Register Portlet</description>
          <portlet-name>RegisterPortlet</portlet-name>
          <display-name xml:lang="EN">Register Portlet</display-name>
          <portlet-class>org.exoplatform.account.webui.component.RegisterPortletApplicationController</portlet-class>
    
          <init-param>
             <name>webui.configuration</name>
             <!--<value>/WEB-INF/conf/portlet/exoadmin/RegisterPortlet/webui/configuration.xml</value>-->
             <value>classpath:portlet/exoadmin/RegisterPortlet/webui/configuration.xml</value>
          </init-param>
          ....
    
    

     

    4) Configure service for sending mails - There is new component called PostRegistrationService in extension archive, which you build in step 1. This component can be configured inside file $GATEIN_HOME/server/default/deploy/registration-extension.ear/registration-extension-war.war/WEB-INF/conf/configuration.xml . Default configuration looks like this:

     

    <component>
       <key>org.jboss.gatein.qa.account.PostRegistrationService</key>
       <type>org.jboss.gatein.qa.account.PostRegistrationService</type>
       <init-params>
         <value-param>
            <name>sendMailAfterRegistration</name>
            <description>Parameter can be used to indicate whether administrator want to be notified about registration of new user.</description>
            <value>true</value>
        </value-param>
        <value-param>
            <name>mailFrom</name>
            <description>This will be used as "from" header in admin mail</description>
            <value>gatein-portal@mydomain.com</value>
        </value-param>
        <value-param>
            <name>mailTo</name>
            <description>This should be admin mail address, where email about registration of new user will be send.</description>
            <value>mposolda@redhat.com</value>
        </value-param>
        <value-param>
            <name>mailSubject</name>
            <description>Subject of mail. Tokens like ${user.userName} will be replaced with real attributes of registered user in final message.     </description>
            <value>Registration of user ${user.userName}</value>
        </value-param>
        <value-param>
            <name>mailMessage</name>
            <description>Content of mail. Tokens like ${user.userName} will be replaced with real attributes of registered user in final message.</description>
            <value>Hi admin,
    
    User ${user.userName} just register himself into your portal. Full data about user:
    
    Username: ${user.userName}
    First name: ${user.firstName}
    Last name: ${user.lastName}
    E-mail: ${user.email}
    
    ----------------------
    This message has been generated automatically as notification about registration of new user into portal.
            </value>
        </value-param>
      </init-params>
    </component>
    

     

    Here is description of parameters:

     

    sendMailAfterRegistration - if you want to disable feature of sending mails after registration of new user, you can change this parameter to false. This way, you will be able to disable feature of sending mails without need to undeploy this extension.

     

    mailFrom , mailTo , mailSubject, mailMessage - Parameters and format of E-mail message to receive. More detailed information is in decription of each attribute

     

    5) Configure your SMTP server configuration - You will also need to configure correctly your SMTP server configuration. This can be done in file $GATEIN_HOME/server/default/conf/gatein/configuration.properties where are some properties in section EMail. For example your properties can look similar to this:

     

    # EMail
    gatein.email.smtp.username=
    gatein.email.smtp.password=
    gatein.email.smtp.host=smtp.corp.redhat.com
    gatein.email.smtp.port=25
    gatein.email.smtp.starttls.enable=false
    gatein.email.smtp.auth=false
    gatein.email.smtp.socketFactory.port=25
    gatein.email.smtp.socketFactory.class=javax.net.SocketFactory
    

     

     

    Detailed documentation about email configuration is here http://docs.jboss.com/gatein/portal/3.1.0-FINAL/reference-guide/en-US/html/chap-Reference_Guide-Configuration.html#sect-Reference_Guide-EMail_Service_Configuration .

     

    6) That's all !!! - Now restart your GateIn portal and try to register new user from page http://localhost:8080/portal/public/classic/register . You should receive email to specified address (from step 4) directly after successful registration of this user.