Django
Configure Django’s SMTP backend and send multipart email.
Before you begin, verify a sending domain and create an API key. Keep the key in your application server’s secret configuration.
Configure Django
Set these values in your Django settings module. Restart your application after changing them.
Use this configuration:
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "smtp.sendy.stanleymasinde.com"
EMAIL_PORT = 2525
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
EMAIL_HOST_USER = "apikey"
EMAIL_HOST_PASSWORD = "API_KEY"
DEFAULT_FROM_EMAIL = "My App <[email protected]>" Replace API_KEY with your full Sendy API key and the sender with an address on your verified domain. Use STARTTLS on port 2525 with the literal username apikey. See Django email documentation.
Send a test email
Open your application’s shell:
python manage.py shellReplace the recipient with your test address, then run:
from django.conf import settings
from django.core.mail import send_mail
send_mail(
subject="Welcome",
message="Your account is ready.",
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=["[email protected]"],
html_message="<h1>Welcome</h1><p>Your account is ready.</p>",
fail_silently=False,
)The shell returns 1 after a successful SMTP submission.
Check the result
Open Emails to confirm the message was queued and follow its status. Successful SMTP submission confirms queuing, not inbox delivery. See Errors for failure guidance.