SMTP – Send email message via SMTP
Block SymbolLicensing group: ADVANCED
Function Description
The SMTP block sends a single email message via standard SMTP protocol. The block acts as a
simple email client. It does not implement a mail server.
Contents of a message is defined by the inputs subj and body. Parameters from and to specify sender and receiver of a message. A message is sent when the TRG parameter is set. Then the BUSY output is set until the request is finished, which is signaled by the DONE output. In case of an error, the ERROR output is set. The errId output carries last error identified by REX Control System error code. The domain parameter must always be set to identify the target device. A default value should work in most cases.
The block may be run in blocking or non-blocking mode which is specified by the BLOCKING parameter. In a blocking mode, the execution of a task is suspended until a request is finished. In a non-blocking mode, the block performs only a single operation depending on available data and the execution of a task is not blocked. It is advised to always run the SMTP block in a non-blocking mode. It is however necessary to mention that on various operating systems some operations may not be performed in a non-blocking mode, so be careful and do not use this block in quick tasks or in tasks with short execution period. The non-blocking operation is best supported on GNU/Linux operating system. A maximal duration of a request performed by the SMTP block is specified by the timeout parameter.
The block supports user authentication using standard SMTP authentication method. User name and password may be specified by the user and password parameters. The block also supports secure connection. An encryption method is selected by the tls parameter. It is also possible to let the block verify server’s certificate by setting the VERIFY parameter. SSL certificate of a server or server’s trusted certificate authority must be stored in the certificate parameter in a PEM format. The block does not support any certificate storage.
Parameters nmax and datamax specify maximum sizes of buffers allocated by the block. The nmax parameter is maximal size of any string parameter. The datamax parameter specifies a maximal size of a data.
Inputs
subj | Subject of the e-mail message | string |
body | Body of the e-mail message | string |
TRG | Trigger of the selected action | bool |
Parameters
server | SMTP server address | string |
to | E-mail of the recipient | string |
from | E-mail of the sender | string |
tls | Encryption method 1 | long |
|
|
|
user | User name | string |
password | Password | string |
domain | Domain name or identification of the target device | string |
auth | Authentication method 1 | long |
|
|
|
certificate | Authentication certificate | string |
VERIFY | Enable server verification (valid certificate) | bool |
timeout | Timeout interval | double |
BLOCKING | Wait for the operation to finish | bool |
nmax | Allocated size of string 0 65520 512 | long |
datamax | Allocated memory for HTTP response 128 65520 | long |
Outputs
BUSY | Sending e-mail | bool |
DONE | E-mail has been sent | bool |
ERROR | Error indicator | bool |
errId | Error code | error |
[Previous] [Back to top] [Up] [Next]