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 Email Account, but in this article we will cover some common examples.
Step-by-step guide
...
- Click on Admin->Manage Email Accounts and add a new inbound accountIn the full repository browser, open the section Email Accounts
- Add an 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 and then check
- Tick the Enabled check- box, then save any changes. (See examples below for POP3 and IMAP)
- Click on Admin->System Configuration->System Directories and make a note of the location of the Import file location e.g. C:\opt\phixflow\data\import. Collected email message will appear in folders beneath this directory.
- 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
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
Location of attachments
Related articles
...
Some examples follow, but also see the section troubleshooting if you have problems connecting to your email account.
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 Folder can be specified, as in the example below. Emails will be read from this folder under the email account.
If you leave Folder blank, emails will be read directly from the Inbox.
Set up file collector to load email messages and/or attachments
Emails will be collected from the email account you have set up, and stored on the PhixFlow server.
For each email PhixFlow will store all attachments, and the email body in text or html format. Inline content (for example inline pictures) will not be stored.
From this store, you can read these files in using a file collector.
Full details for this configuration are in File Collector, but in this article we will go through a typical set up which should cover most cases.
The file collector will need to have the following settings (see also the screen shot below):
Field | Value | ||||||
---|---|---|---|---|---|---|---|
Source Type | Managed File | ||||||
File Type | The type of the attached file, or for reading the email message itself (the body), probably CSV | ||||||
File Location Strategy | All Files in Folder | ||||||
Tag | If a tag is being set (see below), the tag name surrounded by double quotes. E.g.:
If a tag is not being set:
| ||||||
Input Directory Expr. |
| ||||||
Directory Pattern Expression |
| ||||||
File Pattern Expression | A pattern to match attached files, e.g. to find attached files with names like
or if you want to read in the email message (the body) for plain text emails this will be just:
or for html messages:
| ||||||
Archive Directory Expression |
|
Setting a tag
You can set a tag for the emails by including
Code Block |
---|
#tagValue |
in the subject line of incoming emails. Note that the resulting tag you use in the file collector will be all in lower case. For example, if incoming emails have a subject line like
PhixFlow input file accounts 20170426 #accDataEmail
then use the tag
Code Block |
---|
"accdataemail" |
in your file collector configuration.
Info | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
You don't need to know emails and attached files are stored on the PhixFlow server to complete 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 section System Directories, a setting File Upload Directory. For example:
If you have not specified a tag in the subject line of your incoming emails, files will appear in directories:
E.g.
If you have specified a tag in the subject line of the emails, files will appear in directories:
E.g. with the tag "accdataemail"
Archiving If you set an archive directory, your files will be moved once they have been read in by the file collector. This will be to:
E.g. if you set the archive directory to "archive" (as in the examples above), your files will be moved to directories like:
or, if you are using the tag "accdataemail":
|
Anchor | ||||
---|---|---|---|---|
|
Troubleshooting
Authentication Errors
The error below indicates that a successful connection has been made to the mail server, on the correct port and protocol, but one or more of several possible authentication errors has occurred:
- Incorrect Password. As well as checking the password is correct, ensure no special characters are being used such as ampersand - these can sometimes cause this error.
- Incorrect Username. Double-check that the username is the actual mailbox name as setup on the mail server, and not the alias or email address, which may sometimes be different.
- Authentication not required. The server is not expecting a user name and password, but we are sending one anyway (the gui doesn't allow you to not set a password). To fix this, add the property mail.smtp.auth=false to Properties.
- Cannot authenticate. In some cases, the details are correct but the server is refusing to allow authentication to take place, due to the authentication protocol being used. For example, this error is received when attempting to connect to Google Mail, because Google requires the username and password to be supplied in an OAuth token.
Timeout / Incorrect Port Error
The error below typically appears after a delay of up to 1 minute, and normally indicates the port number being used is the wrong one for the type of operation.
Incorrect Host or Port Error
The error below appears if the port number is not in use at all. This error also occurs if the host name is incorrect.
No Secure Connection
The error below usually occurs if attempting to authenticate without sending the username and password via an encrypted tunnel, when the server requires one. This error essentially says that no authentication details were provided, because the mail server is not allowing them to be sent in plain text. This can usually be resolved by supplying the two properties in the configuration:
Code Block |
---|
mail.smtp.auth=true |
which says that authentication will be used and
Code Block |
---|
mail.smtp.starttls.enable=true |
which creates a secure / encrypted connection before sending the authentication details.
Related articles
Page Properties | |||
---|---|---|---|
| |||
|