Initial commit: DMH Patient Registration Flask app
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""
|
||||
Minimal, PII-free confirmation email sender with STARTTLS support.
|
||||
Email delivery failure never rolls back registration.
|
||||
"""
|
||||
|
||||
import os
|
||||
import smtplib
|
||||
from email.message import EmailMessage
|
||||
|
||||
|
||||
def send_confirmation_email(*, to_email: str, reference_form_id: str, status: str) -> None:
|
||||
"""Send minimal registration acknowledgement without raw PII or KYC attachments."""
|
||||
host = os.getenv("SMTP_HOST", "localhost")
|
||||
port = int(os.getenv("SMTP_PORT", "587"))
|
||||
use_tls = os.getenv("SMTP_USE_TLS", "true").strip().lower() in ("1", "true", "yes")
|
||||
sender = os.getenv("SMTP_FROM", "noreply@dmhospital.org")
|
||||
|
||||
msg = EmailMessage()
|
||||
msg["Subject"] = f"DMH Patient Registration Received - Ref {reference_form_id}"
|
||||
msg["From"] = sender
|
||||
msg["To"] = to_email
|
||||
msg.set_content(
|
||||
f"Dear Patient,\n\n"
|
||||
f"Your registration request has been received.\n"
|
||||
f"Reference Form ID: {reference_form_id}\n"
|
||||
f"Current Status: {status}\n\n"
|
||||
f"Deenanath Mangeshkar Hospital Support Team\n"
|
||||
)
|
||||
|
||||
with smtplib.SMTP(host, port, timeout=10) as smtp:
|
||||
smtp.ehlo()
|
||||
if use_tls:
|
||||
smtp.starttls()
|
||||
smtp.ehlo()
|
||||
user = os.getenv("SMTP_USER", "")
|
||||
pwd = os.getenv("SMTP_PASSWORD", "")
|
||||
if user and pwd:
|
||||
smtp.login(user, pwd)
|
||||
smtp.send_message(msg)
|
||||
Reference in New Issue
Block a user