WSO2 Identity Server 2 min

WSO2TORIAL: Using tenant specific SMTP settings for Email service

Sidharth Dash
Integration Specialist

When we create a multi-tenant environment in any of the WSO2 product a lot of tenant specific configurations are available and some of them not. That’s were Yenlo comes to the rescue!

In this blog I will concentrate on making email SMTP settings tenant specific in Identity Server and how it effects the end user. However, this approach can be applied to any of the WSO2 products.


  • Creating multiple tenants as described here.
  • Configuring different E-Mail templates for different tenant as described here.
  • Configuring user account locking and disabling as described here.


When we change axis2.xml parameters there is no specification about the tenant. If one user from tenant1 another from tenant2 locks their account than they will receive E-Mail from a single user account. To make it tenant specific first we have to modify existing axis2.xml and then write custom code.

My Approach:

1. Modifying <CARBON_HOME>/repository/conf/axis2/axis2.xml

Add for each tenant name a new transportSender configuration. Just like this sample.

<transportSender name="tenant1.com" class="org.apache.axis2.transport.mail.MailTransportSender">

<parameter name="mail.smtp.from">admin@tenant1.com</parameter>

<parameter name="mail.smtp.user">tenant1user</parameter>

<parameter name="mail.smtp.password">password</parameter>

<parameter name="mail.smtp.host">smtp.tenant1.com</parameter>

<parameter name="mail.smtp.port">587</parameter>

<parameter name="mail.smtp.starttls.enable">true</parameter>

<parameter name="mail.smtp.auth">true</parameter>

<parameter name="mail.smtp.tenant">tenant1.com</parameter>


<transportSender name="tenant2.com"class="org.apache.axis2.transport.mail.MailTransportSender">

<parameter name="mail.smtp.from">admin@tenant2.com</parameter>

<parameter name="mail.smtp.user">tenant2user</parameter>

<parameter name="mail.smtp.password">password</parameter>

<parameter name="mail.smtp.host">smtp.tenant2.com</parameter>

<parameter name="mail.smtp.port">587</parameter>

<parameter name="mail.smtp.starttls.enable">true</parameter>

<parameter name="mail.smtp.auth">true</parameter>

<parameter name="mail.smtp.tenant">tenant2.com</parameter>


2. Modifying






3. We added this new as a pre-build JAR to the blog.

yenlo.identity.mgt.mail.TenentEmailSendingModule class

Add this .jar to:


and restart the server to deploy.

What this class will do:

  1. Check which tenant the current user belongs to;
  2. Get the SMTP configuration of this specific tenant;
  3. If the tenant email configuration for a tenant is not found in your AXIS2.xml file it will use the default email configuration.

When we set up multi-tenant environment we want to modify every bit of product to be it tenant specific. Following this tutorial you are able to use tenant specific SMTP configurations.

Full API lifecycle Management Selection Guide

whitepaper hero
Get it now
We appreciate it
Care to share

Please select one of the social media platforms below to share this pages content with the world