====== Send e-mail - FUPLA ====== {{:en:mervis-ide:35-help:sendmailtrig.png}} ===== Block name ===== SENDMAILTRIG ===== ST call ===== It is better to use the [[en:mervis-ide:35-help:035-software_basic:060-libraries:035-communications:005-emails:005-sendmail|sendmail]] block for ST programs. ===== Library ===== MESSAGING ===== Version ===== V1.0 ===== Description ===== 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.   ===== Inputs ===== |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 | ===== Outputs ===== |Output|Type|Description | |RESULT|SINT|Numeric status; result of the system settings check| ===== Function ===== 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//. {{:en:mervis-ide:35-help:sendmail_1.png}} 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. {{:en:mervis-ide:35-help:sendmail_2.png}} 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| \\ ===== Application example ===== This function is typically used to send alarm messages. The sending of an e-mail is launched by the alarm status appearance. Another e-mail is sent whe the alarm is reset and launched again. Alarm is active as soon as the //teplota// variable goes over the //teplotni_limit// value.\\ {{:en:mervis-ide:35-help:sendmailtrig_example.png}}