Send email from Python over SMTP
Python's smtplib talks SMTP directly. Point it at Unitpost on port 587 with STARTTLS. Django and Flask wrap this; this page is the bare client.
Send with smtplib
Pythonimport os import smtplib from email.message import EmailMessage msg = EmailMessage() msg["From"] = "you@yourdomain.com" msg["To"] = "customer@example.com" msg["Subject"] = "Hello from Python" msg.set_content("Sent via SMTP.") msg.add_alternative("<p>Sent via SMTP.</p>", subtype="html") with smtplib.SMTP("smtp.unitpost.com", 587) as smtp: smtp.starttls() smtp.login("unitpost", os.environ["UNITPOST_API_KEY"]) smtp.send_message(msg)