#!/bin/bash
# Hermithire — safe daily send: 3 batches of 40, 4hrs apart, 35s between emails
# ~120 emails/day, well under Zoho 200/day limit
# Run with: nohup caffeinate -i bash send_today.sh &

LOG="/Users/archieshouse/hermithire-campaign/tracking/send_today.log"
CAMP="/Users/archieshouse/hermithire-campaign"

log() { echo "[$(date '+%H:%M:%S')] $1" | tee -a "$LOG"; }

log "=== Today's send started (3 batches × 40, 4hr gaps) ==="

log "--- Batch 1 of 3 ---"
python3 "$CAMP/campaign.py" send --touch 1 --limit 40 2>&1 | tee -a "$LOG"
log "Batch 1 done. Waiting 4 hours..."
sleep 14400

log "--- Batch 2 of 3 ---"
python3 "$CAMP/campaign.py" send --touch 1 --limit 40 2>&1 | tee -a "$LOG"
log "Batch 2 done. Waiting 4 hours..."
sleep 14400

log "--- Batch 3 of 3 ---"
python3 "$CAMP/campaign.py" send --touch 1 --limit 40 2>&1 | tee -a "$LOG"
log "=== All done. $(date) ==="
