import logging import base64 import os import resend from config import settings logger = logging.getLogger(__name__) _LOGO_PATH = os.path.join(os.path.dirname(__file__), "assets", "bell_systems_horizontal_darkMode.png") try: with open(_LOGO_PATH, "rb") as _f: _LOGO_B64 = base64.b64encode(_f.read()).decode() _LOGO_SRC = f"data:image/png;base64,{_LOGO_B64}" except Exception: _LOGO_SRC = "" def send_email(to: str, subject: str, html: str) -> None: """Send a transactional email via Resend.""" 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 _OPT_IN_URL = "https://play.google.com/apps/testing/com.bellsystems.vesper" _APP_URL = "https://play.google.com/store/apps/details?id=com.bellsystems.vesper" def send_device_assigned_email( user_email: str, serial_number: str, device_name: str, user_name: str | None = None, ) -> None: """ Notify a user that a BellSystems device has been assigned to their account, with links to opt in to the Vesper beta programme and download the app. """ greeting = f"Dear {user_name}," if user_name else "Dear valued customer," html = f""" Your BellSystems Device Is Ready
{"BellSystems" if _LOGO_SRC else "

BELLSYSTEMS

"}

Device Activation

{greeting}

Exciting news — your BellSystems {device_name} has been assigned to your account and is ready to use!

To get started, join the Vesper programme and download the companion app from the Google Play Store. The app gives you full control over your device, including scheduling, customisation, and real-time monitoring.

Join the Vesper Programme
Download on Google Play
Device Model
BellSystems {device_name}
Serial Number
{serial_number}
Getting Started
1   Click Join the Vesper Programme above to opt in via the Google Play testing programme.
2   Download the Vesper app from the Google Play Store.
3   Sign in with your account and your device will appear automatically.

If you have any questions or need assistance with setup, our support team is always happy to help.

BellSystems.gr

Questions? Contact us at support@bellsystems.gr

If you did not expect this notification, please disregard this message.

""" send_email( to=user_email, subject=f"Your BellSystems {device_name} is ready — get started now!", html=html, )