How to send transactional emails in Django using Zoho ZeptoMail
- Published : March 9, 2026
- Last Updated : March 19, 2026
- 0 Views
- 5 Min Read
Email delivery is a core requirement for most Django applications. From user verification emails to password resets and system notifications, reliable email sending is essential for application workflows.
Django has a in-built email framework that can be leveraged for sending transactional emails. You can use both SMTP as well as email APIs to send these emails. This article explains how to integrate ZeptoMail with Django using both approaches, and covers common scenarios such as sending emails to multiple recipients and adding attachments.

Email sending in Django using SMTP
Python has a separate smtplib module for SMTP emails. However, there are wrappers that help you work natively in Django. They’re available in the django.core.mail module. These wrappers help you develop and test email-sending easily. You can configure ZeptoMail as your SMTP provider and continue using Django’s standard email utilities.
Step 1: Set up ZeptoMail account
Before configuring email-sending from Django, you should set up ZeptoMail. This involves creating an account, adding your domain, and verifying DNS records so messages can be delivered correctly.
Once you verify your domain, you can use the SMTP credentials to send emails from your Django application. To obtain the credentials:
- Navigate to the desired Agent and go to the SMTP/API section.
- You’ll be using the values in the next step.
- Go to the SMTP tab and copy the user name and password.
Note:
- Ensure you match the correct port value with the certification. 465 → SSL; 587 → TLS
- For better security, ZeptoMail supports TLS v1.2 and above only.
Step 2: Configure SMTP settings in Django
To configure the SMTP settings, go to the settings.py file in your project’s folder. Use the following configuration to connect ZeptoMail’s SMTP with your Django application.
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.zeptomail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'ZeptoMail SMTP username'
EMAIL_HOST_PASSWORD = 'ZeptoMail password'
DEFAULT_FROM_EMAIL = 'from address'
Step 3: Email sending using SMTP
Once configured, you can send emails using Django’s send_mail function. Go to the views.py file of your application and paste the following code. The example given below sends a plain-text email.
from django.core.mail import send_mail
send_mail(
subject='Welcome to our app',
message='Thanks for signing up.',
from_email='no-reply@yourdomain.com',
recipient_list=['user@example.com'],
)To send plain-text and HTML emails
To send HTML content along with the plain-text, modify the above code as given below.
from django.core.mail import send_mail
send_mail(
subject='Hello!',
message='This is an acknowledgement for your action on our website',
from_email='rebecca@zylker.com',
recipient_list=['sam@zylker.com'],
html_message='<p>This is an acknowledgement for your action on our website</p>'
)
Step 4: Using attachments in emails
You can include attachments using the EmailMessage class and the attach method. Before you upload, ensure you have the image in your working directory.
To use an uploaded image, add the following code in the views.py file of your application project.
from django.core.mail import EmailMessage
email = EmailMessage(
subject='Your Invoice',
body='Please find your invoice attached.',
from_email='no-reply@yourdomain.com',
to=['user@example.com'],
)
email.attach_file('invoice.pdf')
email.send()Send emails with inline images
Apart from attachments, you can also add inline images to your emails. Add the following code in the views.py file to use them.
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
from django.core.mail.message import EmailMessage
email_message = EmailMessage(
subject='Hello!',
body='This is an acknowledgement for your action on our website',
from_email='rebecca@zylker.com',
to=['sam@zylker.com']
)
# Text file (Read mode 'r')
with open('/example/attachment.txt', 'r') as file:
mime_text = MIMEText(file.read())
mime_text.add_header(
'Content-Disposition', 'attachment; filename=attachment.txt')
email_message.attach(mime_text)
# Binary file (Read mode 'rb')
with open('/example/attachment.jpg', 'rb') as file:
mime_image = MIMEImage(file.read())
mime_image.add_header(
'Content-Disposition', 'inline; filename=attachment.jpg')
email_message.attach(mime_image)
email_message.send()
Step 5: Test email-sending
Once you’ve configured SMTP and made the necessary changes to your application code, you can test it using the following function.
python manage.py runserver
Sending emails using the ZeptoMail email API
ZeptoMail’s Email API allows Django applications to send emails programmatically using structured requests.
This approach provides greater flexibility and is suitable for applications that require advanced email composition. To send emails using APIs, you should install ZeptoMail’s python SDK in your Python environment.
Step 1: Install ZeptoMail SDK
pip install django-zoho-zeptomail
Step 2: Set up ZeptoMail
Once you’ve installed the SDK file, you should add ZeptoMail’s API credentials to the systems.py file. This is the send mail token available in your ZeptoMail account.
EMAIL_BACKEND = 'zoho_zeptomail.backend.zeptomail_backend.ZohoZeptoMailEmailBackend'
DEFAULT_FROM_EMAIL = 'rebecca@zylker.com'
ZOHO_ZEPTOMAIL_API_KEY_TOKEN = 'Send Mail Token'
ZOHO_ZEPTOMAIL_HOSTED_REGION = 'zeptomail.zoho.com'Note:
It’s mandatory to add the region in which your application server is hosted. Example: If your server is hosted in Canada, the URL should be zeptomail.zoho.ca.
Generating the Send Mail Token
Select the Agent you want to connect to your application.
Navigate to the SMTP/API tab. This will open the Setup Details page.
- Copy the Agent-specific Send Mail token under the API tab.
Agents → SMTP/API → Send Mail Token → Click to copy icon
Note: Ensure you use the domain or sender address configured in the chosen Agent as your From address to avoid any disruptions while sending emails.
Step 3: Email-sending using API
Use the code given below in your views.py file to send a plain-text email. The code sample is similar to the one used in SMTP.
from django.core.mail import send_mail
send_mail(
subject='Hello!',
message='This is an acknowledgement for your action on our website',
from_email='rebecca@zylker.com',
recipient_list=['sam@zylker.com']
)To send plain-text and HTML emails
Similar to SMTP, you can include plain-text as well as HTML sections in your email. Use the code given below to do that.
from django.core.mail import send_mail
send_mail(
subject='Hello!',
message='This is an acknowledgement for your action on our website',
from_email='rebecca@zylker.com',
recipient_list=['sam@zylker.com'],
html_message='This is an acknowledgement for your action on our website'
)Template variables are populated using the merge_info object.
Step 4: Using attachments
You can add attachments to your emails using the following code snippet.
from django.core.mail.message import EmailMessage
email_message = EmailMessage(
subject='Hello!',
body='This is an acknowledgement for your action on our website',
from_email='rebecca@zylker.com',
to=['sam@zylker.com']
)
# Text file (Read mode 'r')
with open('/example/attachment.txt', 'r') as file:
email_message.attach('attachment.txt', file.read())
# Binary file (Read mode 'rb')
with open('/example/attachment.jpg', 'rb') as file:
email_message.attach('attachment.jpg', file.read())
email_message.send()Adding inline images
Similar to SMTP, you can add inline images to your emails using the EmailMessage class.
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
from django.core.mail.message import EmailMessage
email_message = EmailMessage(
subject='Hello!',
body='This is an acknowledgement for your action on our website',
from_email='rebecca@zylker.com',
to=['sam@zylker.com']
)
# Text file (Read mode 'r')
with open('/example/attachment.txt', 'r') as file:
mime_text = MIMEText(file.read())
mime_text.add_header(
'Content-Disposition', 'attachment; filename=attachment.txt')
email_message.attach(mime_text)
# Binary file (Read mode 'rb')
with open('/example/attachment.jpg', 'rb') as file:
mime_image = MIMEImage(file.read())
mime_image.add_header(
'Content-Disposition', 'inline; filename=attachment.jpg')
email_message.attach(mime_image)
email_message.send()
Step 5: Send test email
You can check your configuration by sending a test email.
python manage.py runserverSend emails to multiple recipients
The examples above show email-sending to a single recipient. To send emails to multiple recipients or include cc/bcc recipients, you can simply add the email addresses with the “to” parameter or add cc and bcc components.
from django.core.mail.message import EmailMessage
email_message = EmailMessage(
subject='Hello!',
body='This is an acknowledgement for your action on our website',
from_email='rebecca@zylker.com',
to=['sam@zylker.com'],['george@zylker.com']
bcc=['john@zylker.com'],
cc=['george@zylker.com'],
reply_to=['samuel@zylker.com']
)
email_message.send()
Wrapping up
ZeptoMail supports Django applications through both SMTP and API-based integrations.By selecting the approach that best matches your application’s requirements, you can ensure reliable transactional email delivery with ZeptoMail. Further, you can review your outgoing emails' performance in the Processed emails section and tweak your email-sending based on your requirement.


