Skip to main content

SMTPSERVER

The SMTPSERVER I/O Server implements a very basic Simple Mail Transfer Protocol (SMTP) server based on a subset of the RFC 821 standard. The SMTP I/O Server is not intended to be used as an ordinary SMTP server in the open Internet, but as an internal server, inside a protected network and not accessible from unknown clients, for SMTP-based M2M communication, or for testing purposes.

HSYCO Configuration

Add an SMTPSERVER I/O Server in the I/O Servers section of the Settings and set its parameters.

note

Note that the SMTPSERVER I/O Server doesn't count in the I/O servers license total, so you don't need an extra I/O Server license to use SMTPSERVER with HSYCO.

Communication

n/a

High Availability

  • Shutdown when inactive: defaults to false.

Options

IDDefaultValuesDescription
port251...65535the SMTP port number. The server listens on the specified port of all available network interfaces.
rawbodyfalsefalsewhen true, the SMTPSERVER returns the whole body message. When false, if the message content is multipart/alternative, it will look for the first text/plain part and return that part only as body
falsestart generating events only after HSYCO is aligned with the current status of the system
threads4> 0the maximum number of concurrent active server threads (equivalent to connected clients).

Datapoints

IDValueR/WDescription
mailJSON stringRA forced event generated when an email message is received.
The event's value is a JSON object containing all headers and the message body.
The body is arranged as an array of the first 64 lines of the body text. Lines after the 64th are ignored.
When the rawbody option is false, if the message content is multipart/alternative and a text/plain part is present, only that part is returned

The following code in Events is an example of how to parse the event's value, assuming "smtp" is the SMTP I/O Server's ID:

function IOEvent(name, value) : {
if (__run == 1 && name "smtp.mail") {
var mail = JSON.parse(value);
messageLog("From: " + mail.from);
messageLog("To: " + mail.to);
messageLog("Date: " + mail.date);
messageLog("Subject: " + mail.subject);
for (i = 0; i < mail.body.length; i++) {
messageLog("Body Line " + (i + 1) + ": " + mail.body[i]);
}
}
}
2016.01.25 18:24:49.582 - IO MONITOR FORCED: smtp.mail = {"from":"My Name <me@example.com>","to":"test@hsyco.com","subject":"This is a test","date":"Mon, 25 Jan 2016 18:24:49 +0100","contenttype":"text/plain:::note
"","body":["My mail body."]}
2016.01.25 18:24:49.590 - From: My Name <me@example.com>
2016.01.25 18:24:49.591 - To: test@hsyco.com
2016.01.25 18:24:49.592 - Date: Mon, 25 Jan 2016 18:24:49 +0100
2016.01.25 18:24:49.592 - Subject: This is a test
2016.01.25 18:24:49.593 - Body Line 1: My mail body.

Release Notes

3.7.0

  • fixed a bug that caused messages without a "Content-type" header in the body to be ignored

3.6.0

  • improved UTF-8 support
  • added support for multipart/alternative messages

3.5.1

  • initial release