Email Event Publisher
Email event publisher is used to publish events in XML, JSON or text formats via email transports.
Prerequisites
Follow the steps below to complete the prerequisites before starting the event publisher configurations.
Edit the email address, username, password and other relevant properties in the <PRODUCT_HOME>/repository/conf/output-event-adapters.xml
file, to point the mail transport sender which is enabled by default in the product, to a valid SMTP configuration as shown in the example below.
<adapterConfig type="email"> <property key="mail.smtp.from">email-address</property> <property key="mail.smtp.user">user-name</property> <property key="mail.smtp.password">password</property> <property key="mail.smtp.host">smtp.gmail.com</property> <property key="mail.smtp.port">587</property> <property key="mail.smtp.starttls.enable">true</property> <property key="mail.smtp.auth">true</property> <!-- Thread Pool Related Properties --> <property key="maxThread">100</property> <property key="keepAliveTimeInMillis">20000</property> <property key="jobQueueSize">10000</property> </adapterConfig>
- In gmail account security settings you may have to enable "Allow less secure apps" option in order to connect account to WSO2 products.
- When SMTP is used with SSL, it is required to extract the certificate of the email server and add it to the trust store of WSO2 DAS. For detailed instructions, see Creating New Keystores - Adding the public key to client-truststore.jks.
Creating an email event publisher
For instructions on creating an email event publisher, see Configuring CEP to Create Alerts.
Configuring global properties
The following global properties can be set for the Email event publisher type in the <CEP_HOME>/repository/conf/input-event-adapters.xml
file. These properties apply to all the publishers of the email
type. If a global property available by default is removed, the default value of the property is considered.
Custom properties cannot be added as global properties.
Property Key | Description | Data Type | Default Value |
---|---|---|---|
mail.smtp.from | The email address used by the publisher to publish events. | String |
abcd@gmail.com
|
mail.smtp.user | The username used by the publisher to publish events via email. | String | abcd |
mail.smtp.password | The password used by the publish events via email. | String | xxxx |
mail.smtp.host | The host of the email server. | String | smtp.gmail.com |
mail.smtp.port | The port of the email server. | Integer | 587 |
mail.smtp.starttls.enable | This property specifies whether STARTTLS encryption is enabled or not. STARTTLS is an extension which enables a plain text connection to be upgraded to an encrypted (SSL or TLS) connection. | Boolean | true |
mail.smtp.auth | This property specifies whether SMTP authentication is enabled or not. | Boolean | true |
minThread | The minimum number of threads (including idle threads) that should be available in the thread pool at a given time. | Integer | 8 |
maxThread | The maximum number of threads (including idle threads) that should be available in the thread pool at a given time. | Integer | 100 |
keepAliveTimeInMillis | The maximum number of milliseconds that idle threads should be kept alive when the total number of threads in the pool exceeds the number of cores in the machine. | Integer | 20000 |
jobQueueSize | The maximum number of milliseconds that idle threads should be kept alive when the total number of threads in the pool exceeds the number of cores in the machine. | Integer | 10000
|
Configuring adapter properties
Specify the Dynamic Adapter Properties, when creating an email event publisher using the management console as shown below.
After entering the above adapter properties, select the Message Format which you want to apply on the published events. Also, click Advanced to define custom output mappings based on the Message Format you selected. For more information on custom output mapping types, see Publishing Events in Various Event Formats.
<to>
element of the event publisher configuration in the <PRODUCT_HOME>/repository/deployment/server/eventpublishers/
directory as follows.
<eventPublisher name="EmailOuputEventAdapter" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher"> ................... <to eventAdapterType="email"> <property name="email.address">user@gmail.com</property> <property name="email.type">text/plain</property> <property name="email.subject">This is a test mail.</property> </to> </eventPublisher>
Adapter Property | Description | Configuration file property | Example |
---|---|---|---|
Email Address | Email address of the client. Register the publisher for multiple email IDs' by separating them with commas. | email.address | user@gmail.com |
Subject | Subject of the email to be sent to the defined email address. | email.subject | This is a test mail. |
Email Type | The email format to be sent to the defined email address.
If you select | email.type | text/plain |
Related samples
For more information on email
event publisher type, see the following sample.