Files
wevads-platform/scripts/warmup-single.sh
2026-02-26 04:53:11 +01:00

73 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# Warmup avec un seul compte
# Usage: ./warmup-single.sh <email> <password> [count]
EMAIL=${1:-"accoff04@accoff04.onmicrosoft.com"}
COUNT=${3:-10}
# Récupérer password si non fourni
if [ -z "$2" ]; then
PASS=$(PGPASSWORD=admin123 psql -U admin -d adx_system -t -A -c "
SELECT admin_password FROM admin.office_accounts
WHERE admin_email = '$EMAIL';
")
else
PASS=$2
fi
echo "Warmup: $EMAIL - Sending $COUNT emails"
# Récupérer seeds
SEEDS=$(PGPASSWORD=admin123 psql -U admin -d adx_system -t -A -c "
SELECT email FROM admin.brain_seeds
WHERE is_active = true
ORDER BY RANDOM()
LIMIT $COUNT;
")
SENT=0
ERRORS=0
for SEED in $SEEDS; do
[ -z "$SEED" ] && continue
RESULT=$(python3 << PYEOF
import smtplib
from email.mime.text import MIMEText
import random
subjects = ["Quick update", "Following up", "Just checking in", "FYI", "Question"]
bodies = ["Hi,\n\nHope you're doing well.\n\nBest", "Hello,\n\nJust wanted to touch base.\n\nRegards"]
try:
msg = MIMEText(random.choice(bodies))
msg['Subject'] = random.choice(subjects)
msg['From'] = '$EMAIL'
msg['To'] = '$SEED'
server = smtplib.SMTP('smtp.office365.com', 587, timeout=30)
server.starttls()
server.login('$EMAIL', '$PASS')
server.sendmail('$EMAIL', '$SEED', msg.as_string())
server.quit()
print("OK")
except Exception as e:
print(f"ERROR:{e}")
PYEOF
)
if [[ "$RESULT" == "OK" ]]; then
((SENT++))
echo "$SENT. $SEED"
else
((ERRORS++))
echo "$SEED: $RESULT"
fi
sleep 2
done
echo ""
echo "=========================="
echo "Results: $SENT sent, $ERRORS errors"