Difference between revisions of "SMTPSERVER"

From HSYCO
Jump to navigation Jump to search
Line 44: Line 44:
 
|-
 
|-
  
|rowspan="2" |connection
+
|mail
|online
+
|JSON string
 
|R
 
|R
|connection established
+
|a forced event generated when an email message is received.<br>The event's value is a JSON object containing all headers and the message body.<br>The body is arranged as an array of the first 64 lines od the body text. Lines after the 64th are ignored.
|-
 
|offline
 
|R
 
|HSYCO can't connect to the Arteco Open Connector server
 
|-
 
 
 
|event
 
|value
 
|W
 
|send an event notification
 
|-
 
 
 
|rowspan="4" |io.&lt;s&gt;.&lt;p&gt;
 
|rowspan="2" |0
 
|R
 
|pin &lt;p&gt; of server &lt;s&gt; successfully set to 0
 
|-
 
|W
 
|set pin &lt;p&gt; of server &lt;s&gt; to 0
 
|-
 
 
 
|rowspan="2" |1
 
|R
 
|pin pin &lt;p&gt; of server &lt;s&gt; successfully set to 1
 
|-
 
|W
 
|set pin &lt;p&gt; of server &lt;s&gt; to 1
 
 
|-
 
|-
  
 
|}
 
|}
  
You can send simple events, with only a text description, by writing a plain text message to the event datapoint, for example:
+
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:
 
 
<pre>
 
init : io connector.event = "this is the description of an event sent to Open Connector wevery time the events code is updated"
 
</pre>
 
 
 
You can also sent any custom XML section data compatibile with the Open Connector protocol specification, by simply passing the full XML string of all relevant sections in the value, including empty sections, after the plain text description. For example, the following function cound be used to send an event with custom XML data:
 
  
 
<pre>
 
<pre>
function OCURLEventDataBlock(text, icon, label, datablock, url) {
+
function IOEvent(name, value) : {
ioSet('connector.event', text + '<cameras />' + datablock +
+
if (__run == 1 && name == "smtp.mail") {
'<io /><web><web-device id="10"><icon id="' + icon + '" /><label>' + label + '</label><target><url>' +
+
var mail = JSON.parse(value);
url + '</url></target></web-device></web>');
+
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]);
 +
}
 +
}
 
}
 
}
 
</pre>
 
</pre>

Revision as of 18:03, 25 January 2016

The SMTP 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 SMTP I/O Server in the I/O Servers section of the Settings and set its parameters:

Communication

n/a

High Availability

  • Shutdown when inactive: defaults to false.

Options

ID Default Values Description
port 25 1...65535 the SMTP port number. The server listens on the specified port of all available network interfaces.
threads 4 > 0 the maximum number of concurrent active server threads (equivalent to connected clients).

Datapoints

ID Value R/W Description
mail JSON string R a 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 od the body text. Lines after the 64th are ignored.

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]);
		}
	}
}

Release Notes

3.5.1

  • initial release


ARTECO is a registered trademark of Arteco Srl.