Sometimes it is necessary to read data into PhixFlow streams from an email account. For example, if orders are always sent to a specified email address in the same format, it can be an easy way to automate their entry into a database or process them.
To do this, you will need to:
- Configure an email polling service.
- Configure a file collector to gather details of the email message (the body) and any attached files.
Set up service to poll an email account for new messages
Full details for this configuration can be found in emailAccount, but in this article we will cover some common examples.
Step-by-step guide
- Click on Admin → Manage Email Accounts,
- Add details for a new account - see examples below for POP3 and IMAP; to make this an inbound account, don't tick the Outbound box
- Click Test Configuration to ensure the settings are correct
- Tick the Enabled box, then save any changes
Example Settings using POP3
With POP3 just the main Inbox is polled for messages
Example Settings using IMAP / Office 365
With the IMAP protocol, a subfolder can be specified
Set up file collector to load email messages and/or attachments
- Send a test email to the account with a data file attached. (Note: If you want to process the message body then sending plain text rather than HTML messages is easier)
- Navigate to the folder named "in" within the Import directory and then open the folder that is named with today's date
- Within this folder here will be a folder for each message, named with a GUID. Open this folder to view the attachment
Full details for this configuration and found in fileCollector, but in this article we will go through a typical set up which should cover most cases.
You don't need to know this to complete the configuration of the file collector, but sometimes you might find it helpful to be able to find the files delivered by the email polling service.
In system configuration you will have, under the tab System Directories, a setting File Upload Directory. For example:
/opt/phixflow/data/upload
If you have not specified a tag in the subject line of your incoming emails, files will appear in directories:
/opt/phixflow/data/upload/default/in/[date]/[long ID]
E.g.
/opt/phixflow/data/upload/default/in/20170426/ab5dcb71868e47c484d6aa78430393d6
If you have specified a tag in the subject line of the emails, files will appear in directories:
/opt/phixflow/data/upload/[tag]/in/[date]/[long ID]
E.g. with the tag "accdataemail"
/opt/phixflow/data/upload/accdataemail/in/20170426/eebb98c20ce04246b0cee073a510ccde