Skip to main content
AhaSend lets Flask send transactional email over SMTP; this guide uses Python’s built-in smtplib and a Flask command to keep sending on the server. Before sending, verify your domain and create an SMTP credential. Use a sandbox credential for these examples so no email is delivered. Keep the username and password in your server’s secret store. Use Python 3.13. Set SMTP_USERNAME, SMTP_PASSWORD and AHASEND_FROM in your shell or secret store. A separate Flask mail extension is not needed.

Install Flask

Save this as quick_send.py:
quick_send.py
Run python quick_send.py. A failure raises an exception and exits with an error.

Add a Flask Command for Your Worker

Save this as app.py. Set AHASEND_TO=recipient@example.com for testing. The command has no public HTTP endpoint. Flask’s command support runs it with the application context active.
app.py
Run flask --app app send-welcome. SMTP acceptance is not inbox delivery; use delivery webhooks to track the outcome. When moving this into a queue worker, read the recipient from an authorized job, save the job result, and review uncertain submissions before retrying. SMTP has no API idempotency key.