from __future__ import annotations import logging import os import httpx logger = logging.getLogger(__name__) RESEND_API_KEY = os.environ.get("RESEND_API_KEY", "") FROM_EMAIL = "MERLx Aperture " async def send_completion_email(to_email: str, job_id: str, aoi_name: str) -> bool: if not RESEND_API_KEY: logger.warning(f"No RESEND_API_KEY — skipping email to {to_email} for job {job_id}") return False html = f"""
MERLx

Your analysis is ready

The satellite analysis for {aoi_name} is complete.

Generated by MERLx Aperture using open satellite data.

""" async with httpx.AsyncClient() as client: resp = await client.post( "https://api.resend.com/emails", headers={"Authorization": f"Bearer {RESEND_API_KEY}"}, json={"from": FROM_EMAIL, "to": [to_email], "subject": f"MERLx Aperture: Analysis ready — {aoi_name}", "html": html}, ) return resp.status_code == 200