import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText import os def send_invoice_email(to: str, invoice_number: str, invoice_url: str): smtp_host = os.getenv("SMTP_HOST", "localhost") smtp_port = int(os.getenv("SMTP_PORT", 1025)) msg = MIMEMultipart('alternative') msg['Subject'] = f"Your Panacea Tax Invoice Receipt - {invoice_number}" msg['From'] = "Panacea " msg['To'] = to html_content = f"""

Panacea Systems

Tax Compliance Receipt

Dear Customer,

Thank you for your purchase. Your payment has been successfully processed and verified. Please click the button below to view or download your compliance tax invoice from Razorpay:

Download Invoice PDF
Invoice Number: {invoice_number}
Hosted URL: {invoice_url}

Integrated compliance notification. If you did not make this purchase, please contact support.

""" msg.attach(MIMEText(html_content, 'html')) try: with smtplib.SMTP(smtp_host, smtp_port) as server: server.sendmail(msg['From'], [to], msg.as_string()) print(f"[Mailhog] Email sent successfully to {to}") return True except Exception as e: print(f"[Mailhog] Error sending email: {e}") return False def send_password_reset_email(to: str, otp_code: str): """Sends a 6-digit OTP verification code for password reset via SMTP/MailHog.""" smtp_host = os.getenv("SMTP_HOST", "localhost") smtp_port = int(os.getenv("SMTP_PORT", 1025)) msg = MIMEMultipart('alternative') msg['Subject'] = f"Acupedia Password Reset Code: {otp_code}" msg['From'] = "Acupedia Security " msg['To'] = to html_content = f"""

Acupedia

Security & Account Recovery

Hello,

We received a request to reset the password for your Acupedia account. Use the 6-digit verification code below to complete the reset process:

{otp_code}

Code expires in 15 minutes

If you did not request this password reset, please ignore this email or contact support if you suspect unauthorized access. Your password will not change until you verify this code.

Acupedia Clinical Knowledge Systems • Automated Security Service

""" msg.attach(MIMEText(html_content, 'html')) try: with smtplib.SMTP(smtp_host, smtp_port) as server: server.sendmail(msg['From'], [to], msg.as_string()) print(f"[Mailhog] Password reset OTP sent successfully to {to}") return True except Exception as e: print(f"[Mailhog] Error sending password reset email: {e}") return False