From b1448fbb95d72db792ec45635c46e8fd03c839d7 Mon Sep 17 00:00:00 2001 From: mag37 Date: Wed, 24 Jul 2024 12:18:23 +0200 Subject: [PATCH] smtp-changes, deprecate ssmtp, suggest msmtp --- notify_DSM.sh | 17 +++++++++++++++-- notify_ssmtp.sh => notify_smtp.sh | 16 ++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) rename notify_ssmtp.sh => notify_smtp.sh (68%) diff --git a/notify_DSM.sh b/notify_DSM.sh index c996f4e..b6e4df0 100644 --- a/notify_DSM.sh +++ b/notify_DSM.sh @@ -1,9 +1,22 @@ ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. +# INFO: ssmtp is depcerated - consider to use msmtp instead. # -# Copy/rename this file to notify.sh to enable email notifications on Synology DSM +# Copy/rename this file to notify.sh to enable the notification snipppet. +# mSMTP/sSMTP has to be installed and configured manually. # The existing DSM Notification Email configuration will be used automatically. # Modify to your liking - changing SendMailTo and Subject and content. +MSMTP=$(which msmtp) +SSMTP=$(which ssmtp) + +if [ -n $MSMPT ] ; then + MAIL=$MSMTP +elif [ -n $SSMTP ] && [ -z $MAIL ] ; then + MAIL=$SSMTP +else + echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1 +fi + send_notification() { Updates=("$@") UpdToString=$( printf "%s\n" "${Updates[@]}" ) @@ -23,7 +36,7 @@ SenderMail=${SenderMail:-$(grep 'eventmail1' $CfgFile | sed -n 's/.*"\([^"]*\)". printf "\nSending email notification.\n" -ssmtp $SendMailTo << __EOF +$MAIL $SendMailTo << __EOF From: "$SenderName" <$SenderMail> date:$(date -R) To: <$SendMailTo> diff --git a/notify_ssmtp.sh b/notify_smtp.sh similarity index 68% rename from notify_ssmtp.sh rename to notify_smtp.sh index 2d80cb4..c62d3ed 100644 --- a/notify_ssmtp.sh +++ b/notify_smtp.sh @@ -1,9 +1,21 @@ ### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. +# INFO: ssmtp is depcerated - consider to use msmtp instead. # # Copy/rename this file to notify.sh to enable the notification snipppet. -# sSMTP has to be installed and configured manually. +# mSMTP/sSMTP has to be installed and configured manually. # Modify to fit your setup - changing SendMailFrom, SendMailTo, SubjectTag +MSMTP=$(which msmtp) +SSMTP=$(which ssmtp) + +if [ -n $MSMPT ] ; then + MAIL=$MSMTP +elif [ -n $SSMTP ] && [ -z $MAIL ] ; then + MAIL=$SSMTP +else + echo "No msmtp or ssmtp binary found in PATH: $PATH" ; exit 1 +fi + send_notification() { Updates=("$@") UpdToString=$( printf "%s\n" "${Updates[@]}" ) @@ -16,7 +28,7 @@ SubjectTag="dockcheck" printf "\nSending email notification.\n" -ssmtp $SendMailTo << __EOF +$MAIL $SendMailTo << __EOF From: "$FromHost" <$SendMailFrom> date:$(date -R) To: <$SendMailTo>