Spaces:
Sleeping
Sleeping
Piers Lyon Claude Opus 4.7 (1M context) commited on
Commit Β·
37eb301
1
Parent(s): e09465e
mailer: separate SMTP_FROM_EMAIL from SMTP_USERNAME
Browse filesPreviously the From-header address came from SMTP_USERNAME, which
forced the auth user to also be the visible sender. That breaks for
transactional relays (e.g. Resend) where SMTP_USERNAME='resend' but
the team wants emails to come from intelligence@curium.co.uk. New
SMTP_FROM_EMAIL env var separates the two; falls back to SMTP_USERNAME
for the M365 / Gmail case where they're identical.
Workflow + setup_gh_secrets.sh updated to handle the new variable.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- .github/workflows/weekly-hunt.yml +1 -0
- mailer.py +14 -3
- scripts/setup_gh_secrets.sh +3 -2
.github/workflows/weekly-hunt.yml
CHANGED
|
@@ -51,6 +51,7 @@ jobs:
|
|
| 51 |
SMTP_HOST: ${{ secrets.SMTP_HOST }}
|
| 52 |
SMTP_PORT: ${{ secrets.SMTP_PORT }}
|
| 53 |
SMTP_FROM_NAME: ${{ secrets.SMTP_FROM_NAME }}
|
|
|
|
| 54 |
# Recipient mapping (referenced from config.yaml as ENV:HENRIETTE_EMAIL)
|
| 55 |
HENRIETTE_EMAIL: ${{ secrets.HENRIETTE_EMAIL }}
|
| 56 |
# Where dry-run emails go
|
|
|
|
| 51 |
SMTP_HOST: ${{ secrets.SMTP_HOST }}
|
| 52 |
SMTP_PORT: ${{ secrets.SMTP_PORT }}
|
| 53 |
SMTP_FROM_NAME: ${{ secrets.SMTP_FROM_NAME }}
|
| 54 |
+
SMTP_FROM_EMAIL: ${{ secrets.SMTP_FROM_EMAIL }}
|
| 55 |
# Recipient mapping (referenced from config.yaml as ENV:HENRIETTE_EMAIL)
|
| 56 |
HENRIETTE_EMAIL: ${{ secrets.HENRIETTE_EMAIL }}
|
| 57 |
# Where dry-run emails go
|
mailer.py
CHANGED
|
@@ -7,11 +7,16 @@ plaintext. Designed to be called from CI (GitHub Actions) where
|
|
| 7 |
credentials are injected as repo secrets.
|
| 8 |
|
| 9 |
Required env vars:
|
| 10 |
-
SMTP_USERNAME β
|
| 11 |
-
|
|
|
|
| 12 |
SMTP_HOST β defaults to smtp.gmail.com
|
| 13 |
SMTP_PORT β defaults to 587 (STARTTLS)
|
| 14 |
SMTP_FROM_NAME β defaults to "Curium Lead Intelligence"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
"""
|
| 16 |
|
| 17 |
from __future__ import annotations
|
|
@@ -43,10 +48,16 @@ def send(
|
|
| 43 |
host = os.environ.get("SMTP_HOST", "smtp.gmail.com")
|
| 44 |
port = int(os.environ.get("SMTP_PORT", "587"))
|
| 45 |
from_name = os.environ.get("SMTP_FROM_NAME", "Curium Lead Intelligence")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
msg = EmailMessage()
|
| 48 |
msg["Subject"] = subject
|
| 49 |
-
msg["From"] = f"{from_name} <{
|
| 50 |
msg["To"] = to_email
|
| 51 |
if reply_to:
|
| 52 |
msg["Reply-To"] = reply_to
|
|
|
|
| 7 |
credentials are injected as repo secrets.
|
| 8 |
|
| 9 |
Required env vars:
|
| 10 |
+
SMTP_USERNAME β SMTP auth username (e.g. 'resend' for Resend, or
|
| 11 |
+
the mailbox address for M365 / Gmail)
|
| 12 |
+
SMTP_PASSWORD β SMTP auth password / API key / app password
|
| 13 |
SMTP_HOST β defaults to smtp.gmail.com
|
| 14 |
SMTP_PORT β defaults to 587 (STARTTLS)
|
| 15 |
SMTP_FROM_NAME β defaults to "Curium Lead Intelligence"
|
| 16 |
+
SMTP_FROM_EMAIL β the address shown in the From header
|
| 17 |
+
(e.g. intelligence@curium.co.uk). If unset,
|
| 18 |
+
falls back to SMTP_USERNAME so existing M365 /
|
| 19 |
+
Gmail setups still work unchanged.
|
| 20 |
"""
|
| 21 |
|
| 22 |
from __future__ import annotations
|
|
|
|
| 48 |
host = os.environ.get("SMTP_HOST", "smtp.gmail.com")
|
| 49 |
port = int(os.environ.get("SMTP_PORT", "587"))
|
| 50 |
from_name = os.environ.get("SMTP_FROM_NAME", "Curium Lead Intelligence")
|
| 51 |
+
# SMTP_FROM_EMAIL lets the From-header address differ from the auth
|
| 52 |
+
# username (needed when using a transactional relay like Resend where
|
| 53 |
+
# SMTP_USERNAME is e.g. 'resend' but the From shows
|
| 54 |
+
# intelligence@curium.co.uk). Falls back to SMTP_USERNAME for
|
| 55 |
+
# M365 / Gmail setups where they're the same.
|
| 56 |
+
from_email = os.environ.get("SMTP_FROM_EMAIL") or user
|
| 57 |
|
| 58 |
msg = EmailMessage()
|
| 59 |
msg["Subject"] = subject
|
| 60 |
+
msg["From"] = f"{from_name} <{from_email}>"
|
| 61 |
msg["To"] = to_email
|
| 62 |
if reply_to:
|
| 63 |
msg["Reply-To"] = reply_to
|
scripts/setup_gh_secrets.sh
CHANGED
|
@@ -105,8 +105,9 @@ echo "SMTP for outbound email"
|
|
| 105 |
prompt_and_set "SMTP_HOST" "SMTP_HOST" visible "smtp.gmail.com"
|
| 106 |
prompt_and_set "SMTP_PORT" "SMTP_PORT" visible "587"
|
| 107 |
prompt_and_set "SMTP_FROM_NAME" "SMTP_FROM_NAME" visible "Curium Lead Intelligence"
|
| 108 |
-
prompt_and_set "
|
| 109 |
-
prompt_and_set "
|
|
|
|
| 110 |
echo
|
| 111 |
|
| 112 |
echo "Recipients (visible β these aren't credentials)"
|
|
|
|
| 105 |
prompt_and_set "SMTP_HOST" "SMTP_HOST" visible "smtp.gmail.com"
|
| 106 |
prompt_and_set "SMTP_PORT" "SMTP_PORT" visible "587"
|
| 107 |
prompt_and_set "SMTP_FROM_NAME" "SMTP_FROM_NAME" visible "Curium Lead Intelligence"
|
| 108 |
+
prompt_and_set "SMTP_FROM_EMAIL" "SMTP_FROM_EMAIL (e.g. intelligence@curium.co.uk)" visible ""
|
| 109 |
+
prompt_and_set "SMTP_USERNAME" "SMTP_USERNAME (auth user β 'resend' for Resend)" silent "$(env_value SMTP_USERNAME)"
|
| 110 |
+
prompt_and_set "SMTP_PASSWORD" "SMTP_PASSWORD (API key / app password)" silent "$(env_value SMTP_PASSWORD)"
|
| 111 |
echo
|
| 112 |
|
| 113 |
echo "Recipients (visible β these aren't credentials)"
|