Difference between revisions of "SMTPSERVER"

From HSYCO
Jump to navigation Jump to search
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
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.
+
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.
  
 
[[Category:I/O Server]]
 
[[Category:I/O Server]]
  
 
== HSYCO Configuration ==
 
== HSYCO Configuration ==
Add an SMTP I/O Server in the [[Settings#I/O Servers|I/O Servers section of the Settings]] and set its parameters:
+
Add an SMTPSERVER I/O Server in the [[Settings#I/O Servers|I/O Servers section of the Settings]] and set its parameters:
  
 
=== Communication ===
 
=== Communication ===
Line 25: Line 25:
 
|1...65535
 
|1...65535
 
|the SMTP port number. The server listens on the specified port of all available network interfaces.
 
|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).
 
|-
 
|-
  
Line 38: Line 44:
 
|-
 
|-
  
|rowspan="2" |connection
+
|mail
|online
+
|JSON string
|R
 
|connection established
 
|-
 
|offline
 
|R
 
|HSYCO can't connect to the Arteco Open Connector server
 
|-
 
 
 
|event
 
|value
 
|W
 
|send an event notification
 
|-
 
 
 
|rowspan="4" |io.<s>.<p>
 
|rowspan="2" |0
 
 
|R
 
|R
|pin <p> of server <s> successfully set to 0
+
|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.
|-
 
|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>
 
<pre>
init : io connector.event = "this is the description of an event sent to Open Connector wevery time the events code is updated"
+
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]);
 +
}
 +
}
 +
}
 
</pre>
 
</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) {
+
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; charset=us-ascii","returnpath":"","body":["My mail body."]}
ioSet('connector.event', text + '<cameras />' + datablock +
+
2016.01.25 18:24:49.590 - From: My Name <me@example.com>
'<io /><web><web-device id="10"><icon id="' + icon + '" /><label>' + label + '</label><target><url>' +
+
2016.01.25 18:24:49.591 - To: test@hsyco.com
url + '</url></target></web-device></web>');
+
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.
 
</pre>
 
</pre>
  
Line 92: Line 82:
 
=== 3.5.1 ===
 
=== 3.5.1 ===
 
*initial release
 
*initial release
 
----
 
 
 
''ARTECO is a registered trademark of Arteco Srl.''
 

Latest revision as of 18:28, 25 January 2016

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:

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


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; charset=us-ascii","returnpath":"","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.5.1

  • initial release