Skip to main content
AhaSend lets Django send email through its built-in SMTP backend; this guide configures STARTTLS and tests both a short send and an application setup. 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 for this Django 5.2 LTS example. Set SMTP_USERNAME, SMTP_PASSWORD and AHASEND_FROM in your local environment before running the code.

Install Django

Save this as quick_send.py:
quick_send.py
Run python quick_send.py. It exits with an error if sending fails.

Configure the Application Backend

Save this as mail_settings.py for the standalone check, or add the settings to your existing Django settings module. They use Django’s SMTP backend.
mail_settings.py
Keep credentials in your deployment’s secret store. EMAIL_USE_TLS enables STARTTLS; port 465 and implicit TLS are unsupported.

Send from Your Application

Save this as send_email.py beside mail_settings.py. Set AHASEND_TO=recipient@example.com for the sandbox check.
send_email.py
Run python send_email.py. In a real Django project, call send_welcome from an authorized backend task using the recipient saved for that user. Save the job’s result and avoid blind retries after a connection closes during submission: SMTP does not offer API idempotency keys. Use webhooks for final delivery outcomes.