""" Email Utility for simulated multi-channel notifications. In a production environment, this would use fastapi-mail or a direct SMTP client. For this Hackathon environment, we log to a central forensic file. """ import aiofiles import os from datetime import datetime from core.logging import get_logger logger = get_logger(__name__) async def send_email(to_email: str, subject: str, body: str): """ Simulated asynchronous email delivery. Logs the payload to /logs/emails.log for forensic verification. """ log_dir = "logs" log_file = os.path.join(log_dir, "emails.log") if not os.path.exists(log_dir): os.makedirs(log_dir) email_payload = f""" {"="*60} TIMESTAMP: {datetime.utcnow().isoformat()} TO: {to_email} SUBJECT: {subject} BODY: {body} {"="*60} """ try: async with aiofiles.open(log_file, mode="a") as f: await f.write(email_payload) logger.info(f"SIMULATED EMAIL SENT TO: {to_email} | SUBJECT: {subject}") return True except Exception as e: logger.error(f"FAILED TO SEND SIMULATED EMAIL: {str(e)}") return False