×

Please give details of the problem

Skip to content

SMTP Adapter

The SMTP Adapter is used to send emails from RunMyProcess DigitalSuite through a local SMTP server.

Prerequisites

The following prerequisites must be fulfilled to install and run the SMTP adapter:

  • You must install the adapter on a local system in your environment. This can either be the system where you have installed the DigitalSuite EnterpriseConnect Agent, or a different one which is able to connect to the Agent's host.

  • You can install the adapter several times in your environment, for example, to work with different SMTP servers. The identifier of the adapter (protocol setting in the handler.config configuration file) must be unique for each of the installations.

  • The SMTP server by which you want to send emails must be running and configured to allow access by the adapter.

Installing the Adapter

To install the adapter:

  1. Download the following ZIP file: unified-adapter-[version].zip

    [version] is the current version number

    The ZIP file contains executables, licences, configuration files, and reference files for several adapters.

  2. Extract the ZIP file to a local folder. The following path is recommended:

    [parent-folder]\adapters\smtp

    [parent-folder] is a folder of your choice. If the EnterpriseConnect Agent is installed on the same machine, use its installation folder as the [parent-folder], for example, C:\ProgramFiles (x86)\dsec-agent.

  3. Copy the configuration files for the SMTP adapter, SMTP.config and handler.config, from the configFiles\smtp.reference subfolder to the configFiles folder, for example:

    1
    copy configFiles\smtp.reference\*.config configFiles
    

    Overwrite existing files in the configFiles folder.

  4. If desired, delete obsolete files. Only the following folders and files are required in the smtp folder to use the adapter:

    1
    2
    3
    4
    5
    6
    7
    smtp
    ├── configFiles
       ├── handler.config
       └── SMTP.config
    ├── lib
       └── unified-adapter-[version].jar
    └── log.properties
    

    In addition, we recommend you keep the following:

    • runAdapter.bat batch file for starting the adapter on Microsoft Windows
    • smtp.reference subfolder in the configFiles folder for reference purposes

Configuring the Adapter

Configuration settings for the SMTP adapter are required in the following configuration files:

Edit the files with a plain text editor.

handler.config

The handler.config file contains general configuration settings for connecting the adapter to the EnterpriseConnect Agent:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#Generic Protocol Configuration
protocol = SMTP
protocolClass = org.runmyprocess.sec2.SMTP
agentHost = 127.0.0.1:8080
pingFrequency = 1000
adapterConnectionInterval = 1000
offlineLogsMaxSize = 100
maxNumberOfLogsInBatch = 100
clusterEnabled = false
clusterAgentsHttpAddressList = localhost:8071,localhost:8072,localhost:8073

The settings have the following meaning:

  • protocol: The identifier of the adapter. If you install the adapter several times in your environment, the identifier must be unique for each of the installations, for example, SMTP1 and SMTP2.
  • protocolClass: The adapter's Java class.
  • agentHost: The IP address and port of the EnterpriseConnect Agent.
  • pingFrequency: The frequency in milliseconds in which the adapter pings the EnterpriseConnect Agent.
  • adapterConnectionInterval: The frequency in milliseconds in which the adapter tries to connect to the EnterpriseConnect Agent.
  • offlineLogsMaxSize: The maximum number of log entries that the adapter collects locally and sends to the EnterpriseConnect Agent when it re-connects to it after it was disconnected.
  • maxNumberOfLogsInBatch: The maximum number of log entries the adapter sends to the EnterpriseConnect Agent at a time. A value of 0 means that the number of log entries sent at a time is unlimited.
  • clusterEnabled: true if the EnterpriseConnect Agent is configured and running as a cluster, false otherwise.
  • clusterAgentsHttpAddressList: The IP addresses and ports of the EnterpriseConnect Agent cluster, if clusterEnabled is set to true.

SMTP.config

The SMTP.config file contains specific settings for the adapter.

The SMTP adapter generates emails by means of the Java Mail API with the properties configured in the configuration file. The individual properties to set depend on the SMTP server you are using.

For example, a configuration for IMAP GMail includes the following settings:

1
2
3
4
mail.smtp.auth=true
mail.smtp.starttls.enable=true
mail.smtp.host=smtp.gmail.com
mail.smtp.port=587

mail.smtp.host and mail.smtp.port specify the host and port of the SMTP server and are required in any case.

Add and remove properties as required by your SMTP server. A full list of Java Mail SMTP properties is available here.

Starting the Adapter

The adapter needs to be running to be able to send mails by means of your local SMTP server.

Before you start the adapter, make sure that the DigitalSuite EnterpriseConnect Agent is running.

To start the adapter:

  1. Change to the smtp installation folder.

  2. Execute the following command, depending on the operating system:

    • On Microsoft Windows: Execute the runAdapter.bat batch file.

    • On Linux: Execute the following command directly, or create and execute a corresponding shell script to do so:

      1
      java -XX:+UseG1GC -XX:+ExitOnOutOfMemoryError -Djava.util.logging.config.file=./log.properties -cp lib/*: org.runmyprocess.sec2.AdapterHandler
      

Using the Adapter

If everything is configured and running correctly, you can place requests from RunMyProcess DigitalSuite to send emails through the local SMTP server.

Request: POST on http://[agent-host]:[port]/, where [agent-host] and [port] are the IP address and port of the EnterpriseConnect Agent.

Content Type: application/json

Accept: application/json

Content (example):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
"protocol":"SMTP",
"data":{
        "username":"user@name.com",
        "password":{
                "encoder":"None",
                "password":"myPassword"
                },
        "from":"sender@name.com",
        "to":"user@somewhere.com",
        "cc":"cc_user@somewhere.com",
        "bcc":"bcc_user@somewhere.com",
        "subject":"HELLO",
        "body":"WORLD",
        "attachedFiles":[
                {
                "name"="Test.ext",
                "data"="SOME BASE 64 DATA" 
                },
                {
                "name"="Test2.ext",
                "data"="SOME OTHER BASE 64 DATA" 
                }
        ]
    } 
}

The password can be encoded in base64 by setting the value base64 for the encoder parameter in the password object and sending the password as base64.

The mail body is encoded in UTF-8. By default, it is sent in html format. By specifying the option "type":"plain", you can send it as plain text.

You can find a sample request like the one above in the smtp.reference\InputJSONExample.txt file in the smtp installation folder.

Return Object:

The expected return is a JSON object that looks as follows:

1
2
3
4
{
"SECStatus":200,
"Message":"Mail Sent!"
}