SMTP_USERNAME, SMTP_PASSWORD and AHASEND_FROM in your local environment before running the code.
Install Django
quick_send.py:
quick_send.py
python quick_send.py. It exits with an error if sending fails.
Configure the Application Backend
Save this asmail_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
EMAIL_USE_TLS enables STARTTLS; port 465 and implicit TLS are unsupported.
Send from Your Application
Save this assend_email.py beside mail_settings.py. Set AHASEND_TO=recipient@example.com for the sandbox check.
send_email.py
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.
Related Guides
- Before sending: verify your domain and create an SMTP credential.
- Connection and message rules: SMTP hosts, ports and limits, special headers, sandbox mode, retention and plan features.
- Other ways to send: REST API, AhaSend CLI, Node.js SDK and Go SDK.
- Delivery events: webhook setup and local webhook testing.

