Receiving XML Events via Email


This application demonstrates how to use siddhi-io-email for receiving events from emails.


  1. Add relevant siddhi-io-email and siddhi-map-xml jars to the {WSO2Home}/lib folder if not exist.

  2. Make sure you have provide less secure access to the sender's email account. e.g.: For Gmail this can be done by visiting

  3. Edit the Siddhi app by providing following details.

    • receiver_email_username
    • receiver_email_password
  4. Give the subject of the email to . For further information search.terms refer

  5. Save this sample.

Executing the Sample:

  1. Start the Siddhi application by clicking on 'Run'.
  2. If the Siddhi application starts successfully, the following messages would be shown on the console.
    ReceiveEmailInXmlFormat.siddhi - Started Successfully!
  3. Send an email with the body in following format to receiver's email address.
  4. The message should be logged in the console.

@source(type='email', @map(type='xml'),
store = 'imap' ,
host = '',
folder = 'INBOX',
ssl.enable = 'true' ,
polling.interval = '30' ,
search.term = 'subject:<subject_of_mail>' ,
content.type = 'text/plain')
define stream SweetProductionStream (name string, amount double);

define stream LowProductionAlertStream (name string, hourlyTotal double, currentHour double);

from SweetProductionStream
select name, sum(amount) as hourlyTotal,
convert(time:extract('HOUR', time:currentTimestamp(), 'yyyy-MM-dd hh:mm:ss'), 'double') as currentHour
insert into LowProductionAlertStream;