fix(brevo): passer X-Sib-Sandbox dans le body email, pas en header HTTP (#87)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Colin Maudry
2026-06-24 16:15:07 +02:00
parent c3408ecc3c
commit 3f1c39d5a6
3 changed files with 34 additions and 30 deletions
+3 -2
View File
@@ -16,8 +16,7 @@ def init_mailer() -> None:
"""Construit le client Brevo à partir des variables d'environnement."""
global _client
api_key = os.getenv("BREVO_API_KEY", "")
headers = {"X-Sib-Sandbox": "drop"} if DEVELOPMENT else None
_client = Brevo(api_key=api_key, headers=headers)
_client = Brevo(api_key=api_key)
def _base_url() -> str:
@@ -40,12 +39,14 @@ def _template_id(env_var: str) -> int:
def _send_template(template_id: int, recipient: str, params: dict) -> None:
assert _client is not None, "Mailer non initialisé (init_mailer() non appelé)"
sandbox_headers = {"X-Sib-Sandbox": "drop"} if DEVELOPMENT else None
try:
_client.transactional_emails.send_transac_email(
template_id=template_id,
params=params,
sender=_sender(),
to=[SendTransacEmailRequestToItem(email=recipient)],
headers=sandbox_headers,
)
except ApiError:
logger.exception(