SENDMAILCUSTOM
PROGRAM TEST_SENDMAILCUSTOM
VAR
TESTEMAIL : BOOL :=TRUE;
HOST : STRING[64] := 'SMTP.DOMAT.CZ';
PORT : UINT := 25;
USER : STRING[64] := 'INFO@DOMAT.CZ';
PASSWORD : STRING[64] := '1234';
SENDER : STRING[64] := 'INFO@DOMAT.CZ';
RECIPIENT : STRING[64] := 'SUPPORT@DOMAT.CZ';
SUBJECT : STRING[64];
MESSAGE : STRING[64];
END_VAR
IF TESTEMAIL THEN
SUBJECT := 'TEST';
MESSAGE := 'TEST EMAIL HAS BEEN SENT.';
MESSAGING.SENDMAILCUSTOM(HOST, PORT, USER, PASSWORD, SENDER, RECIPIENT, SUBJECT, MESSAGE);
TESTEMAIL := FALSE;
END_IF;
END_PROGRAM
MESSAGING
V1.0
The function sends an e-mail in each PLC computing cycle. It is highly recommended to be used in ST code only to prevent occassional flooding of the recipient with many e-mails of the same contents. Using this function, it is possible to specify the e-mail sender account and credentials in the program (this is not possible with functions sendmail and sendmailtrig where these data are entered in the channel definition). If You want to send more than one email at the time, You have to use this block multiple times or create some sort of switcher for addresses. PLC is capable of sending one email at the certain moment, so more emails needs to be sent with gaps. The gap between emails should be at least 1 second, but ideally even more.
Input | Type | Description |
---|---|---|
HOST | STRING_REF | reference to variable with the SMTP server name |
PORT | UINT | TCP port number where the SMTP server is listening |
USERNAME | STRING_REF | reference to variable with user name used to access the SMTP server |
PASSWORD | STRING_REF | reference to variable with password used to access the SMTP server |
CHANNEL | STRING_REF | reference to variable with the communication connection definition (set in PLC properties, see below) |
FROM | STRING_REF | reference to variable with e-mail address from which the mail is sent |
TO | STRING_REF | reference to variable with the recipient's address |
SUBJECT | STRING_REF | reference to variable with the e-mail subject |
MESSAGE | STRING_REF | reference to variable with the e-mail body text |
Output | Type | Description |
---|---|---|
=> | SINT | Numeric status; result of the system settings check |
At each of the function calls, a e-mail is sent from the predefined from e-mail account username to the to address. The e-mail subject is taken from the subject variable, and the e-mail body from the message variable.
This function has not defined the connection parameters for the SMTP server in the Channel definition. The connection parameters must be defined in the variables which are linked to the host, port, username, and password inputs. This means that the parameters may be changed by the application program, and the user account name may be different for different e-mail messages.
Remember to coeck the SMTP server availability from the network where the PLC is running.
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 |
This function is typically used to send alarm messages. The sending of an e-mail is launched by the alarm status appearance. See the ST call above for example.