import logging import resend from config import settings logger = logging.getLogger(__name__) def send_email(to: str, subject: str, html: str) -> None: """Send a transactional email via Resend. Logs errors but does not raise.""" try: resend.api_key = settings.resend_api_key resend.Emails.send({ "from": settings.email_from, "to": to, "subject": subject, "html": html, }) logger.info("Email sent to %s — subject: %s", to, subject) except Exception as exc: logger.error("Failed to send email to %s: %s", to, exc) raise def send_device_assignment_invite( customer_email: str, serial_number: str, device_name: str, customer_name: str | None = None, ) -> None: """Notify a customer that a Bell Systems device has been assigned and shipped to them.""" greeting = f"Dear {customer_name}," if customer_name else "Dear Customer," html = f"""

BELLSYSTEMS

Device Shipment Confirmation

{greeting}

Your Bell Systems {device_name} device has been successfully manufactured and shipped. We are delighted to have it on its way to you!

To get started, download our controller application from the Google Play Store and follow the in-app setup instructions.

Download on Google Play
Device
Bell Systems {device_name}
Serial Number
{serial_number}

Thank you very much. We greatly appreciate your choice in our products.

BellSystems.gr

If you did not expect this email, please contact us at support@bellsystems.gr

""" send_email( to=customer_email, subject=f"Your Bell Systems {device_name} is on its way! 🎉", html=html, ) def send_device_provisioned_alert( admin_email: str, serial_number: str, hw_type: str, ) -> None: """Internal alert sent to an admin when a device reaches provisioned status.""" html = f"""

Device Provisioned

A Vesper device has successfully provisioned and is ready to ship.

Serial Number {serial_number}
Board Type {hw_type.upper()}

View in Admin Console

""" send_email( to=admin_email, subject=f"[Vesper] Device provisioned — {serial_number}", html=html, )