#!/bin/bash
# Usage: echo "body text" | ./taler-hacktivism-email-helper.sh email@example.com
# Needs ``swaks'' to be installed.
TO="$1"
SUBJECT="Taler Merchant Auth Code"
BODY=$(cat)

# SMTP password: set SMTP_PASSWORD in the environment (not stored in git).
# Live container may still use a literal in-file password — do not re-commit it.
swaks --server mail.cyon.ch \
      --port 587 \
      --auth LOGIN \
      --auth-user taler-merchant@hacktivism.ch \
      --auth-password "${SMTP_PASSWORD:?set SMTP_PASSWORD}" \
      --tls \
      --from taler-merchant@hacktivism.ch \
      --to "$TO" \
      --header "Subject: $SUBJECT" \
      --body "$BODY"
