fix gmail send error
This commit is contained in:
36
notify.sh
36
notify.sh
@@ -37,29 +37,43 @@ send_ntfy() {
|
||||
fi
|
||||
}
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Function: Send to Gmail
|
||||
send_gmail() {
|
||||
if [ -n "$GMAIL_USER" ] && [ -n "$GMAIL_TO" ] && [ -n "$GMAIL_PASS" ]; then
|
||||
echo "[Gmail] Sending..."
|
||||
echo -e "${YELLOW}======================================${NC}"
|
||||
echo -e "${YELLOW}Gmail SMTP Email${NC}"
|
||||
echo -e "${YELLOW}======================================${NC}"
|
||||
echo ""
|
||||
echo -e "From: ${GREEN}$GMAIL_USER${NC}"
|
||||
echo -e "To: ${GREEN}$GMAIL_TO${NC}"
|
||||
echo -e "SMTP: ${GREEN}smtp.gmail.com:587${NC}"
|
||||
echo ""
|
||||
|
||||
# Send via curl (portable, no sendmail needed)
|
||||
if curl -s --url "smtps://smtp.gmail.com:465" --ssl-reqd \
|
||||
SUBJECT="$ICON $TITLE"
|
||||
BODY="$MESSAGE"
|
||||
|
||||
email_content="To: $GMAIL_TO\nSubject: $SUBJECT\n\n$MESSAGE"
|
||||
response=$(echo "$email_content" | curl --ssl-reqd \
|
||||
--url "smtp://smtp.gmail.com:587" \
|
||||
--user "$GMAIL_USER:$GMAIL_PASS" \
|
||||
--mail-from "$GMAIL_USER" \
|
||||
--mail-rcpt "$GMAIL_TO" \
|
||||
--upload-file - <<EOF
|
||||
From: $GMAIL_USER
|
||||
To: $GMAIL_TO
|
||||
Subject: $ICON $TITLE
|
||||
--upload-file - \
|
||||
--silent \
|
||||
--show-error 2>&1)
|
||||
|
||||
$MESSAGE
|
||||
EOF
|
||||
then
|
||||
exit_code=$?
|
||||
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
echo "[Gmail] Sent."
|
||||
else
|
||||
echo "[Gmail] Failed."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Function: Send to Telegram
|
||||
|
||||
Reference in New Issue
Block a user