SMTP – Send e-mail message via SMTP

Block SymbolLicensing group: ADVANCED
PIC

Function Description
The SMTP block sends a single e-mail message via standard SMTP protocol. The block acts as a simple e-mail client. It does not implement a mail server.

The 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 the last error identified by REXYGEN system error code. The domain parameter must always be set to identify the target device. The default value should work in most cases. There can be multiple recipients of the message. In such a case, the individual e-mail addresses must be comma-separated and no space character may be present.

The block may be run in non-blocking or blocking mode, which is specified by the BLOCKING parameter.

  • In the blocking mode, the execution of a task is suspended until the sending of e-mail is completed. This mode is typically used in tasks with long execution period, TS 10s. If the e-mail is not successfully sent until timeout expires, an error is indicated and the execution of the task is resumed.
  • In the non-blocking mode, the SMTP block performs only a single operation in each execution of the block and the execution of a task is not suspended. This mode is typically used in tasks with short execution period, TS 0.1s. In this mode, the timeout parameter should be set to at least 50 TS, where TS is the execution period in seconds.

It is recommended to run the SMTP block in the non-blocking mode. It is however necessary to mention that on various operating systems some operations may not be performed in the non-blocking mode, so be careful and do not use this block in quick tasks (see QTASK) or in tasks with extremely short execution period (few milliseconds). The non-blocking mode is best supported on GNU/Linux operating system.

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. The 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.

The length of the whole message (subject, body and headers) is limited to a maximum of 1024 characters.

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 (I32)

1 ....

None

2 ....

StartTLS

3 ....

TLS

user

User name

String

password

Password

String

domain

Domain name or identification of the target device

String

auth

Authentication method  1

Long (I32)

1 ....

Login

2 ....

Plain

certificate

Authentication certificate

String

VERIFY

Enable server verification (valid certificate)

Bool

timeout

Timeout interval

Double (F64)

BLOCKING

Wait for the operation to finish

Bool

Outputs

BUSY

Sending e-mail

Bool

DONE

E-mail has been sent

Bool

ERROR

Error indicator

Bool

errId

Error code

Error

2020 © REX Controls s.r.o., www.rexygen.com