-
Notifications
You must be signed in to change notification settings - Fork 1
Module thc_MailAlert
Andreas Drollinger edited this page Nov 8, 2019
·
14 revisions
This module provides functions to send mail alerts.
Configures the mail delivery method. Mails can be delivered either via a custom mail procedure (method=custom), or using the Tcl smtp package. For this second case the mail delivery can either be managed by the main THC Tcl process (method=direct_sync) or by a specific Tcl process (method=direct_async). This latest method avoids eventual interruptions of the main THC Tcl process in case the SMTP server response is delayed.
Parameters | Description |
---|---|
-method <DeliveryMethod> | Mail delivery method. Has to be 'custom', 'direct_sync' or 'direct_async' (default) |
[-custom_command <CustomCommand>] | Specifies the custom mail command that will be called if the custom delivery method is selected. The argument list of the custom command and the use of the Unix mail command 'mail' is shown in the example below. |
[-direct_args <Direct delivery arguments>] | Arguments transferred to smtp::sendmessage if one of the direct mail delivery methods is selected |
-debug 0|1 | If set to 1 some additional log information are displayed that help debugging the email delivery method. Default: 0 |
-
# 1)
package require tls
thc::MailAlert::Configure \
-method direct_async \
-direct_args {-servers mail.my_host.com -ports 25
-username my_name@my_host.xyz -password my_pw_123
-usetls 1}
# 2)
thc::MailAlert::Configure \
-method custom \
-custom_command mail_custom_send
proc mail_custom_send {Title Message RecipientList From} {
# Backslash double quotes
regsub -all "\"" $Message "\\\"" Message
regsub -all "\"" $Title "\\\"" Title
# Call the Unix mail command to send the message
exec bash -c "echo \"$Message\" | mail -s \"$Title\" -r $From $RecipientList"
}
Sends a mail message. Send sends a mail message to one or to multiple destination addresses. To use this command the command mail needs to be available and configured.
Parameters | Description |
---|---|
-to <ToAddress> | Destination address. Multiple addresses can be specified by repeating this argument |
[-from <From>] | Sender address. Default: localhost |
[-title <Title>] | Message title |
Message | Mail message |
-
thc::MailAlert::Send -to knopf@vaucher.ch -to 0041791234567@sms.ecall.ch \
-from myhome.vaucher@bluewin.ch -title "Alarm alert" \
"Sensor $Sensor triggered"
THC, Tight Home Control - See THC index register - THC repository on github.com/Drolla/thc