Enabling Notifications for User Operations

This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Enabling Notifications for User Operations

The primary objective of this is to send a notification to an external endpoint once a user operation has taken place. For example, you want to send an email to an email address once a new user is created or the password of an existing user is changed. This can be achieved by enabling notifications for user operations.

The configuration differs based on the type of notifications you want to send to the external endpoint. The following instructions provide information on how to send an email when a user operation takes place.

  1. Enable axis2 email transport sender by uncommenting the relevant section in the <PRODUCT_HOME>/repository/conf/axis2/axis2.xml file and add your SMTP provider values to it. The following is an example of the uncommented MailTransportSender

    • mail.smtp.from - The mail address from where you want to send the notification. It can be any working mail address.

    • mail.smtp.user - User name of the the mail you have provide in mail.smtp.from.

    • mail.smtp.password - Password of the mail you have provided in mail.smtp.from.

    • mail.smtp.host - The SMTP server to connect to.

    • mail.smtp.port - The SMTP server port to connect to, if the connect() method does not explicitly specify one. Defaults to 25.

    • mail.smtp.starttls.enable - If true, enables the use of the STARTTLS command (if supported by the server) to switch the connection to a TLS-protected connection before issuing any login commands. Note that an appropriate trust store must configured so that the client will trust the server's certificate. Defaults to false.

    • mail.smtp.auth - If true, attempt to authenticate the user using the AUTH command. Defaults to false.

    For information about the SMTP, see here.

    <transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender"> <parameter name="mail.smtp.from">wso2demomail@gmail.com</parameter> <parameter name="mail.smtp.user">wso2demomail</parameter> <parameter name="mail.smtp.password">mailpassword</parameter> <parameter name="mail.smtp.host">smtp.gmail.com</parameter> <parameter name="mail.smtp.port">587</parameter> <parameter name="mail.smtp.starttls.enable">true</parameter> <parameter name="mail.smtp.auth">true</parameter> </transportSender>
  2. Configure the <PRODUCT_HOME>/repository/conf/identity/msg-mgt.properties file with the desired destination configurations and template configurations. The following is a sample configuration for sending an email to an email address on user operation event. 

    For example user operations can be account recovery, account locking/disabling, ask password.

    module.name.1=email email.subscription.1=userOperation email.subscription.userOperation.template=/home/user/Desktop/johnsmith (If you are using windows machine the path would be C:\Users\Administrator\Desktop\johnsmith) email.subscription.userOperation.salutation=Admin email.subscription.userOperation.subject=User operation change information email.subscription.userOperation.endpoint.1=privateMail email.subscription.userOperation.endpoint.privateMail.address=receiver@gmail.com email.subscription.userOperation.endpoint.privateMail.salutation=Admin private mail email.subscription.userOperation.endpoint.privateMail.subject=User operation change information to private mail

    Before going into a detailed description about each property, one of the important facts that you must keep in your mind is that the properties included in this file can be secured using secure vault. You may refer Carbon Secure Vault Implementation in the WSO2 Product Administration Guide for more information on how to use secure vault to encrypt sensitive information in this property file. The following table lists out the properties and their description  (You can click on the column header to scroll through the description).