Integration guide · Django

Django SMTP: seven lines in settings.py

send_mail, password resets and notifications: Django sends through SMTP Senpai with the standard SMTP backend.

  • 14-day free trial
  • Servers and data in the EU
  • A log of every delivery
4.7/5 · 83 reviewsGoogleCapterraTrustpilot
settings.py
import os

EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "relay.mailsenpai.com"
EMAIL_PORT = 2525
EMAIL_USE_TLS = True  # STARTTLS
EMAIL_HOST_USER = os.environ["SMTP_USER"]
EMAIL_HOST_PASSWORD = os.environ["SMTP_PASS"]
DEFAULT_FROM_EMAIL = "[email protected]"
the 4 details

Four details, and your emails go out

They are the same for every program: you also find them, already filled in, in your customer area.

Serverrelay.mailsenpai.com
Port2525
SecuritySTARTTLS
Username and passwordin the customer area, SMTP Senpai page

The sender must be on a domain verified in your area: otherwise the server refuses to send. For SPF, DKIM and DMARC records, use the free email DNS checker.

how to

Three steps

1

Copy the details

Username and password from the customer area, in environment variables.

2

Update settings.py

Paste the lines: EMAIL_USE_TLS turns on STARTTLS on port 2525.

3

Test it

python manage.py sendtestemail [email protected]

Frequently asked questions

EMAIL_USE_TLS or EMAIL_USE_SSL?

EMAIL_USE_TLS = True: port 2525 uses STARTTLS. Do not turn on EMAIL_USE_SSL.

Does it work with Celery?

Yes: tasks that call send_mail use the same SMTP backend.

What about Flask or FastAPI?

The same four details work with smtplib and any SMTP library in Python.

Try SMTP Senpai with your own software

A 14-day trial: connect your software, send your real emails and check the log line by line. Then decide.

14 days freeFree trial