One of our clients asked us to build a process that would extract information from messages arriving at a given email inbox, transform it, and write it to a data model. We haven't posted anything about the Continual Processing toolkit yet, but it's a good fit for this kind of thing – except that we didn't have an email reading input channel yet!
To complete this task, we'd need a source that we could configure to read an IMAP folder, translate each new message into an internal event, and then use our model toolset to update the client's model.
Starting with Continual build 0.2.29, we'll include ImapMailboxMonitor, which you can configure as follows:
{
"class": "io.continual.services.processor.library.email.sources.ImapMailboxMonitor",
"mailImapServer": "imap.gmail.com",
"mailLogin": "johndoe@example.com",
"mailPassword": "${MY_MAIL_PASSWORD}",
"folder": "inbox",
// optional
"pollEveryMins": 5,
// our class needs to note its high-water mark persistently
"tracker":
{
"class": "io.continual.services.processor.library.email.sources.FileSeenTracker",
"file": "./data/inboxTrack.txt"
}
}
This source component reads the designated folder periodically. (The javax.mail IMAP watch functionality seemed flakey, and we don't have near-real-time requirements, so polling works well enough for now.) When an email arrives, it's converted into a Processing message and handed off to the configured processing pipeline.