Receiving email, Part 1: Setting up a topic and an email address

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

As of FME Server 2019+, this functionality can be completed using FME Server Automations. For more information, please see Run a Workspace in Response to Incoming Email. Note that this tutorial series will no longer be updated, if you encounter an error, please contact Safe Support.

 

Introduction

This tutorial is part of the series Email in FME Server. The following three articles cover how to set up FME Server to receive emails. This first article covers creating the Publication, either using FME Server's internal SMTP service or using the IMAP protocol to allow FME Server to monitor a pre-existing external mail server, in addition, we will set up a Topic to record the incoming email message as a string of JSON.

 

Step-by-step Instructions

Create a Topic

In order to receive emails, FME Server must be set up to publish these incoming notifications to a topic. The first step is to set up a topic. Since a topic is just a named “channel” all this involves is giving the topic a name and description.

  1. In FME Server, in the menu on the left-hand side under Notifications select Topic, on this page select ‘New’.newtopic.pngCreate a New Topic from the Topic Notifications home page
     
  2. Set the Topic Name to RECIEVE_EMAIL, then set the Description to:

    Email Tutorials

    This is a topic that will be used by FME Server to monitor incoming emails

    Then click OK to create the Topic. createtopic.png

    Complete the topic configuration

     

  3. The topic will show up in the list of topics.
    topiclist.png

New topic now listed

 

Create an email publication

Next, we create the email publication. The publication is the part of the Notification services that picks up any new emails in an inbox and is what will send the corresponding message to a topic.

 

There are two methods for receiving emails with FME Server:

Option 1: SMTP Protocol

This service uses FME’s built-in email server, by specifying a username emails can be sent indirectly to the host, upon which a message will be sent to the registered topic we just created.

Create a new Publication, on the Notifications page go to Publications > New

Set the following parameters:

  • Publication Name: IncomingEmailDemo

  • Protocol: Email (SMTP)

  • Email User Name: demoEmailUser

  • Topics To Publish To: RECEIVE_EMAIL

Click OK, and you will see your publication in the list.

The email address is created simply by taking the Email User Name parameter followed by your server hostname:

demoEmailUser@myfmeserver.mydomain

createsmtpnotification.png

Configure new SMTP publication with a new username

 

Option 2: IMAP Protocol

The second option requires you to give FME Server IMAP access to watch an account on an external mail server for incoming emails. The following example is set up to use Gmail.

Create a new Publication, on the Notifications page go to Publications > New

Enter the parameters as follows:

  • Publication Name: IncomingEmailDemo

  • Protocol: Email (IMAP)

The Protocol settings will depend on your account. SSL and TLS with basic authentication are supported for security.

  • Poll Interval: This is how often you would like FME Server to check the Account for new emails

  • Emails to fetch: Do you want to retrieve all unread messages or new emails only?

 

Additional Optional Parameters:

  • Subject Filter: If entered, only fetches emails where the subject contains said string (see more info below)

  • Download Attachments To: Select a location to save email attachments. This can be from within the FME Server Resources, or you can specify the UNC path to another directory.

createimapnotification.png

Configure the IMAP Publication

 

Subject Filtering

To process emails for different purposes coming to the same address, you can enter a subject filter. If it is set, only emails with a subject containing the filter text will result in a notification being sent to the registered topic. The subject filter can be plain text or a regular expression. For example, to accept emails for three different projects, you could use the following expression:

project105|project481|project722

You would then need to filter these emails accordingly in the processing workspace. There is an example of this in the next section of this tutorial.

 

Testing the Configuration

To ensure you have correctly set up the Topic and Notification, you can turn on Topic Monitoring and then send an email to the appropriate email account. If you are using IMAP, this will be your mail server email account specified in the Notification configuration (e.g. fmeserver@gmail.com in the example). If you are using SMTP, this will be demoEmailUser@myFMEServer.mydomain.

  1. On the Notifications page select the Topic Monitoring tab and then select the topic we created earlier (RECEIVE_EMAIL). Once the topic has been selected monitoring should be started automatically.
  2. In a new tab, send an email from a different email account than the one used to set up the Publication to the email used to set up the Publication, either demoEmailUser@myFMEServer.mydomain or e.g. fmeserver@gmail.com

    Note: Ensure that you change myFMEServer.mydomain to your actual server name and domain.

  3. Go back to the Topic Monitoring page and check to see if the RECEIVE_EMAIL topic worked correctly. You might have to wait up to 5 minutes depending on the Poll Interval that was set up in the Publication.

topicmonitoring.png

Topic Monitoring page on FME Server

Note: You must keep this page open in the web browser else topic monitoring may be interrupted. Open a separate tab to send the email. If you have correctly set up the service a json message will be returned detailing the information related to said email.

 

Conclusion

In this section of the “Receiving email” tutorials, we have set up an email topic and publication. By enabling FME Server to receive emails this will allow you to trigger different protocols in response to these emails through subscriptions to the topic. Read on to learn how to create a workspace that uses these emails.

 

Troubleshooting

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.