From f2a62821d686fd621cf53202c4be6a36d2ec7146 Mon Sep 17 00:00:00 2001 From: deajan Date: Sun, 23 Oct 2016 14:02:52 +0200 Subject: [PATCH] Basic sendemail busybox implementation --- dev/ofunctions.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dev/ofunctions.sh b/dev/ofunctions.sh index 76ba668..3397b60 100644 --- a/dev/ofunctions.sh +++ b/dev/ofunctions.sh @@ -1,6 +1,6 @@ #### MINIMAL-FUNCTION-SET BEGIN #### -## FUNC_BUILD=2016102307 +## FUNC_BUILD=2016102308 ## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## To use in a program, define the following variables: @@ -301,6 +301,20 @@ function SendAlert { if [ "$mail_no_attachment" -eq 0 ]; then attachment_command="-a $ALERT_LOG_FILE" fi + + if [ "LOCAL_OS" == "BUSYBOX" ]; then + if type sendmail > /dev/null 2>&1; then + echo "$body" | $(type -p sendmail) -f "$SENDER_EMAIL" -S "$SMTP_SERVER:$SMTP_PORT" -au "$SMTP_USER" -ap "$SMTP_PASS" + if [ $? != 0 ]; then + Logger "Cannot send alert mail via ($type -p sendmail) !!! "WARN" + return 1 + fi + else + Logger "Sendmail not present. Won't send any mail" "WARN" + return 1 + fi + fi + if type mutt > /dev/null 2>&1 ; then echo "$body" | $(type -p mutt) -x -s "$subject" $DESTINATION_MAILS $attachment_command if [ $? != 0 ]; then