SENDMAILTRIG
It is better to use the sendmail block for ST programs.
MESSAGING
V1.0
The function sends an e-mail at each transition of the control variable send from FALSE to TRUE. If more than one email has to be sent at a time, this block must be used multiple times or a sort of switcher for addresses must be created. PLC is capable of sending one email at a moment only, so more emails need to be sent with time gaps. The gap between emails should be at least 1 second, but ideally even more.
Input | Type | Description |
CHANNEL | STRING | communication connection definition (set in PLC properties, see below) |
FROM | STRING | e-mail address from which the mail is sent |
RECIPIENT | STRING | recipient's e-mail address |
SUBJECT | STRING | e-mail subject |
MESSAGE | STRING | e-mail body text |
SEND | BOOL | command to send the e-mail |
Output | Type | Description |
RESULT | SINT | Numeric status; result of the system settings check |
Each rising edge on the send input sends an e-mail from the predefined from e-mail account to the recipient address. The e-mail subject is taken from the subject variable, and the e-mail body from the message variable.
The channel variable refers to the predefined communication channel. This has to be created in the PLC properties: doubleclick the PLC and select Message definition, then right-click the context menu and Add alarm channel.
Now, define the channel name which is the value of the channel variable. Then, the SMTP connection type must be defined: click to select the channel and set the SMTP server to be used for e-mail sending, and TCP port which the server uses for communication. If the server requires login, set Use login to true and then fill in the User name (most probably the e-mail address) and Password. Finally, confirm all changes by clicking OK in the red dialogue.
Note that the SMTP server must be accessible by the PLC: check default gateway settings, DNS server etc.
The output variable result indicates the result of the system settings check.
Value | Description |
0 | OK |
8 | E-mail queue full |
16 | Unknown channel |
24 | Error - impossible to determine the status |
other | Internal error - contact Domat Control System support |