Last Updated on August 2, 2026 by ian
Django has a built-in email framework that makes sending transactional email straightforward. This guide shows you how to configure ConvertNow as your Django email backend, send your first email, and handle common patterns like welcome emails, password resets, and HTML templates.
Step 1: Configure your email backend
Add these settings to your settings.py:
# settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'out.convertnow.co'
EMAIL_PORT = 465
EMAIL_USE_SSL = True # Implicit SSL on port 465
EMAIL_USE_TLS = False # Do not combine with EMAIL_USE_SSL
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = env('CONVERTNOW_API_KEY') # Store in environment
DEFAULT_FROM_EMAIL = 'My App <[email protected]>'
Tip: Use django-environ or python-decouple to load EMAIL_HOST_PASSWORD from your .env file rather than hardcoding it.
Step 2: Send your first email
Django’s send_mail function is the simplest way to send a single email:
from django.core.mail import send_mail
send_mail(
subject='Welcome to MyApp',
message='Thanks for signing up. Your account is ready.',
from_email='[email protected]',
recipient_list=['[email protected]'],
html_message='<h1>Welcome!</h1><p>Your account is ready.</p>',
fail_silently=False,
)
Step 3: Send email from a view
The typical pattern in a Django registration view:
from django.core.mail import send_mail
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
import json
@csrf_exempt
def signup(request):
if request.method != 'POST':
return JsonResponse({'error': 'POST required'}, status=405)
data = json.loads(request.body)
name = data['name']
email = data['email']
# Create user in your database...
send_mail(
subject=f'Welcome to MyApp, {name}!',
message=f'Hi {name}, your account is ready.',
from_email='[email protected]',
recipient_list=[email],
html_message=f'<h1>Hi {name}!</h1><p>Your account is ready.</p>',
)
return JsonResponse({'success': True})
Step 4: HTML templates with Django templates
For richer emails, use Django’s template engine to render HTML:
# templates/emails/welcome.html
{# Welcome email template #}
<!DOCTYPE html>
<html>
<body>
<h1>Hi {{ name }}!</h1>
<p>Your account is ready. <a href="{{ login_url }}">Log in here</a>.</p>
</body>
</html>
from django.core.mail import EmailMultiAlternatives
from django.template.loader import render_to_string
def send_welcome_email(user):
context = {
'name': user.first_name,
'login_url': 'https://myapp.com/login',
}
html_content = render_to_string('emails/welcome.html', context)
text_content = f'Hi {user.first_name}, your account is ready.'
msg = EmailMultiAlternatives(
subject=f'Welcome to MyApp, {user.first_name}!',
body=text_content,
from_email='[email protected]',
to=[user.email],
)
msg.attach_alternative(html_content, 'text/html')
msg.send()
Step 5: Send email with attachments
from django.core.mail import EmailMessage
def send_invoice(user, invoice_pdf_bytes):
email = EmailMessage(
subject=f'Your invoice #{invoice_number}',
body='<p>Please find your invoice attached.</p>',
from_email='[email protected]',
to=[user.email],
cc=['[email protected]'],
)
email.content_subtype = 'html' # Main content is HTML
email.attach(
filename='invoice.pdf',
content=invoice_pdf_bytes,
mimetype='application/pdf',
)
email.send()
Step 6: Send to multiple recipients
from django.core.mail import send_mass_mail
# send_mass_mail takes a tuple of (subject, message, from, [recipients])
messages = [
(
f'Welcome, {user.first_name}!',
f'Hi {user.first_name}, your account is ready.',
'[email protected]',
[user.email]
)
for user in new_users
]
send_mass_mail(messages, fail_silently=False)
Testing emails in development
During development, use Django’s console backend to print emails instead of sending them:
# settings.py (development only)
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
Or use the file backend to save emails to disk:
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = BASE_DIR / 'sent_emails' # Directory will be created automatically
Common errors and fixes
SMTPAuthenticationError
Cause: wrong username or password. The USERNAME must be your email address (not “apikey” — that’s a SendGrid pattern). The PASSWORD must be your cn_live_ API key.
SMTPConnectError on port 465
Make sure EMAIL_USE_SSL = True and EMAIL_USE_TLS = False. These two settings are mutually exclusive — setting both will cause a connection error.
Start sending for free — convertnow.co — no credit card required

