From 6472fe639aa6d10565dc1548466dedec8bb9f2f1 Mon Sep 17 00:00:00 2001 From: Tien Ngo Date: Mon, 29 Dec 2025 16:57:11 +0700 Subject: [PATCH] refactor: replace sendmail with curl for Gmail notifications --- notify.sh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/notify.sh b/notify.sh index de64937..06c1e8d 100644 --- a/notify.sh +++ b/notify.sh @@ -40,21 +40,25 @@ send_ntfy() { # Function: Send to Gmail send_gmail() { if [ -n "$GMAIL_USER" ] && [ -n "$GMAIL_TO" ] && [ -n "$GMAIL_PASS" ]; then - if ! command -v sendmail &> /dev/null; then - echo "[Gmail] Warning: sendmail not found, skipping." - return - fi echo "[Gmail] Sending..." - { - echo "Subject: $ICON $TITLE" - echo "From: $GMAIL_USER" - echo "To: $GMAIL_TO" - echo "" - echo "$MESSAGE" - } | sendmail -S smtp.gmail.com:587 \ - -au"$GMAIL_USER" \ - -ap"$GMAIL_PASS" \ - "$GMAIL_TO" && echo "[Gmail] Sent." || echo "[Gmail] Failed." + + # Send via curl (portable, no sendmail needed) + if curl -s --url "smtps://smtp.gmail.com:465" --ssl-reqd \ + --user "$GMAIL_USER:$GMAIL_PASS" \ + --mail-from "$GMAIL_USER" \ + --mail-rcpt "$GMAIL_TO" \ + --upload-file - <