Skip to content

jrpereirajr/iris-imap-inbound-adapter-demo

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
img
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

iris-imap-inbound-adapter-demo

A simple implementation of IMAP protocol as an IRIS Interoperability Inbound Adapter

What The Sample Does

This sample presents an interoperability production which is composed by a business service and a business operation. The business service uses the IMAP inbound adapter to check for new messages every 10 seconds. Such adapter relies on an simple IMAP client implementation. This code was inspired by the Demo.Loan.FindRateProduction interoperability sample.

In short, this production:

  • Uses the GetMessageUIDArray method to get all available messages in the configured mailbox
  • Loop over them tracing their output - fetched by Fetch method
  • Check if each message subject match to a criteria - start by "[IMAP test]"
  • If message subject matches the criteria, a response is sent back to the sender; otherwise, the message is ignored
  • Delete all of them in the end - so they won’t be analysed again.

In this example an IMAP server from Yahoo Mail was configured - imap.mail.yahoo.com, on port 993. The default IRIS SSL configuration ISC.FeatureTacker.SSL.Config was used.

A SMTP server was configured as weel, in order to receive acknolodge messages in response to messages grabbed through IMAP. As for IMAP, Yahoo Mail was used for SMTP - smtp.mail.yahoo.com, port 465. Please, onfigure one recipient in "Recipient" field.

Note that user and password were stored in a credential called imap-test.

As you can see in the image below, the production starts and keeps querying the IMAP server for new messages. When there’re new messages, the inbound adapter grabs their information - like from header and subject, and lets production be able to take further actions based on such information.

The action taken in this example was to check if the message subject starts with "[IMAP test]" and send back a message to the sender.

When a message doesn’t match the criteria, it is just ignored by production.

Python implementation

As a use case for using new Embedded Python, the IMAP adpater is also implemented using imaplib Python lib. With such feature you can import and use Python libraries directly in your ObjectScript classes:

You can check out the code in dc.demo.imap.python package.

Prerequisites

Make sure you have git and Docker desktop installed.

Installation: ZPM

Coming soon...

Installation: Docker

Clone/git pull the repo into any local directory

$ git clone https://github.com/intersystems-community/iris-imap-inbound-adapter-demo.git

Open the terminal in this directory and run:

$ docker-compose build
  1. Run the IRIS container with your project:
$ docker-compose up -d

How to Run the Sample

Set dc.demo.imap.IMAPTestService and dc.demo.imap.IMAPTestSendEmailOperation parameters, configure credentials with user/password to your IMAP and SMTP server and naming it as imap-test, like explained above. Then open the production and start it. A few secondes later you should start to see trace information with information on grabbed messages from the server in the Event Log page.

About

A simple implementation of IMAP protocol as an IRIS Interoperability Inbound Adapter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published