From 3218efe0c304c2ba6f313d48bda3907d1c93cafc Mon Sep 17 00:00:00 2001 From: hoelee Date: Thu, 11 Jun 2026 09:00:00 +0800 Subject: [PATCH] feat(shell-sync): send_notification() part 3/3 --- platform/shell-sync/sync.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/platform/shell-sync/sync.sh b/platform/shell-sync/sync.sh index 2a95b258..d63e8190 100644 --- a/platform/shell-sync/sync.sh +++ b/platform/shell-sync/sync.sh @@ -122,3 +122,17 @@ send_notification() { esac } > "$config" + IFS=',' read -r -a recipients <<< "$SMTP_TO" + if printf 'From: %s\nTo: %s\nSubject: %s\n\n%s\n' "$SMTP_FROM" "$SMTP_TO" "$subject" "$body" \ + | msmtp --file="$config" "${recipients[@]}" >> "$NOTIFICATION_LOG" 2>&1; then + rm -f "$config" "$NOTIFICATION_FAILURE_FILE" + log "Notification sent: $subject" + return 0 + fi + + rm -f "$config" + printf '%s %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$subject" > "$NOTIFICATION_FAILURE_FILE" + log "Notification delivery failed; container will remain unhealthy until a notification is sent successfully. Check $NOTIFICATION_LOG" + return 1 +} +