Problem
How do I set up outbound SMTP using the Django framework for Python?
How do I use outMail with Django?
Solution
In this article we discuss using outMail as the outbound email server with Django. We assume already you have a working development environment with Django installed and you are looking at just configuring the SMTP Server settings to use outMail.
Installing Django
Please refer to the Django documentation.
Create a blank project using django-admin startproject OutmailTest.
This will create a folder called OutmailTest with files underneath it
You can run and test the blank project by changing directory into the folder OutmailTest and running the command python manage.py runserver. The web project should then be visible from http://localhost:8000.
Configuring Django to send emails with outMail.
With in your project edit the file called settings.py. Add the following lines to the file
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'mxXXXXX.smtp-engine.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'outMail-username'
EMAIL_HOST_PASSWORD = 'outMail-password'
Sending an email with Django.
The below snippet shows an example of how to send emails with Django.
from django.core.mail import send_mail
from django.conf import settings
send_mail(
subject='Subject goes here....',
message='Hello World!!',
from_email=me@example.com,
recipient_list=[toAddress@example.com])
Summary of server details
Outgoing server |
mxXXXXXX.smtp-engine.com As provided in your signup email. |
Outgoing server protocol |
SMTP |
Outgoing server port |
25, 465, 587, 2525 or 8025 |
Authentication Type |
Basic Authentication, SSL and TLS supported |
Username |
As provided |
Password |
As provided |