Browse Source

replace env var RECIPIENT_ADDRESS with MAIL_TO (inserted in To: header, now supporting multiple recipients)

Fabian Peter Hammerle 3 years ago
parent
commit
f77d66d639
5 changed files with 19 additions and 8 deletions
  1. 7 0
      CHANGELOG.md
  2. 1 1
      Dockerfile
  3. 1 1
      README.md
  4. 2 2
      docker-compose.yml
  5. 8 4
      monitor.sh

+ 7 - 0
CHANGELOG.md

@@ -5,6 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 ## [Unreleased]
+### Added
+- support multiple recipients
+
+### Changed
+- replaced environment variable `RECIPIENT_ADDRESS` with `MAIL_TO`
+- recipients are inserted in `To:` header
+
 ### Fixed
 - `docker-compose`: drop capabilities
 

+ 1 - 1
Dockerfile

@@ -19,7 +19,7 @@ ENV TOR_HOST= \
     ONION_SERVICE_PORT= \
     TIMEOUT_SECONDS=4 \
     SLEEP_DURATION=16s \
-    RECIPIENT_ADDRESS= \
+    MAIL_TO= \
     VERBOSE=
 
 COPY --chown=report:nobody monitor.sh /

+ 1 - 1
README.md

@@ -19,7 +19,7 @@ $ sudo docker run -d --network tor \
     -e TOR_HOST=tor_proxy -e TOR_PORT=9050 \
     -e ONION_SERVICE_HOST=change-me.onion \
     -e ONION_SERVICE_PORT=80 \
-    -e RECIPIENT_ADDRESS=me@example.com \
+    -e MAIL_TO=me@example.com,someone@else.com \
     --name onion_service_monitor  \
     fphammerle/onion-service-status-mail
 ```

+ 2 - 2
docker-compose.yml

@@ -23,8 +23,8 @@ services:
       ONION_SERVICE_PORT: 80
       # TIMEOUT_SECONDS: 8
       # SLEEP_DURATION: 1m
-      RECIPIENT_ADDRESS: change.me@domain.tld
-      # VERBOSE: 1
+      MAIL_TO: change.me@domain.tld, another@recipient.com
+      #VERBOSE: 1
     volumes:
     - mail_queue:/var/spool/dma:rw
     cap_drop: [ALL]

+ 8 - 4
monitor.sh

@@ -11,8 +11,8 @@ elif [ -z "$ONION_SERVICE_HOST" ]; then
 elif [ -z "$ONION_SERVICE_PORT" ]; then
     echo 'missing $ONION_SERVICE_PORT'
     exit 1
-elif [ -z "$RECIPIENT_ADDRESS" ]; then
-    echo 'missing $RECIPIENT_ADDRESS'
+elif [ -z "$MAIL_TO" ]; then
+    echo 'missing $MAIL_TO'
     exit 1
 fi
 
@@ -29,8 +29,12 @@ send_report() {(
     if [ ! -z "$VERBOSE" ]; then
         set -x
     fi
-    echo -e "From: ${sender_address}\nSubject: $ONION_SERVICE_HOST:$ONION_SERVICE_PORT $1\n" \
-        | sendmail "$RECIPIENT_ADDRESS"
+    sendmail -t <<EOF
+From: $sender_address
+To: $MAIL_TO
+Subject: $ONION_SERVICE_HOST:$ONION_SERVICE_PORT $1
+
+EOF
 )}
 
 last_state=""