Lesson 7 / 22 · Commentail 1.3.2
An HTTP API is useful when your mail service provides sending credentials over HTTPS. Commentail uses Django's backend contract; here Anymail connects it to Resend. This is an optional provider choice. Check availability, account limits and pricing before connecting.
Prepare the sender and key
Add your domain in Resend, publish the supplied DNS records and wait for verification. Choose a sender on that domain and a recipient permitted by the account's current restrictions.
Create a dedicated practice-site API key with sending access; full access is unnecessary. Restrict it to the practice domain when available. Save the value at creation because the dashboard cannot display it again. Set RESEND_API_KEY='YOUR_API_KEY' and DEFAULT_FROM_EMAIL='Comments <comments@YOUR_VERIFIED_DOMAIN>' using lesson 5. Keep actual credentials out of articles and Git.
Install the backend
In the site's virtual environment:
python -m pip install django-anymail
In the active settings file:
import os
# Add once to the existing list.
INSTALLED_APPS += ["anymail"]
EMAIL_BACKEND = "anymail.backends.resend.EmailBackend"
DEFAULT_FROM_EMAIL = os.environ["DEFAULT_FROM_EMAIL"]
ANYMAIL = {
"RESEND_API_KEY": os.environ["RESEND_API_KEY"],
"REQUESTS_TIMEOUT": 20,
}
Add anymail only once and merge with an existing ANYMAIL dictionary. The 20-second timeout is below Commentail's default 300-second job lease. SMTP settings are unnecessary for this backend. Only one EMAIL_BACKEND is active.
Restart the website and worker. Run the system check and complete the guest flow in lesson 6. Installing Anymail does not validate the key or sender. Inspect the provider's sending event and actual inbox receipt separately.
Keep the same Commentail outbox and schedule. No second API-mail queue is needed. Do not replace per-message retries with Celery retries: Commentail owns the message state and deadlines. Webhooks are unnecessary for this initial integration. If you later add delivery tracking, configure signature validation according to Anymail's documentation rather than exposing an unauthenticated endpoint.
After the experiment revoke the dedicated test key. If the site will remain in use, replace it with a production key and verify delivery after restarting.
Official instructions: Anymail Resend backend, Anymail installation, Resend API key management.
Related lessons
- 5. Environment variables without key confusion
- 8. Schedule email processing and cleanup
- 21. Troubleshoot a Commentail installation
Choose a sign-in method or comment as a guest below.