Matt Seymour

The Django send_mail function is a really simply way to be able to send an email via Django. It requires setting only a few parameters and Django settings in order to be able to send emails from your application.

A common question asked when using Django send_mail is how do I set the reply-to email header.


tldr; Use the EmailMessage class set the header (named argument) to {'Reply-To':'reply-to@example.com'}


What is Reply-To?

Reply-To serves as a way to respond to an email but to a different email address than an email was originally from. For example an email may be sent from a server (server@example.com) but the reply-to address maybe to an admin (admin@example.com); this will mean if you choose to reply to the message from server@example.com you will be sending an email to admin@example.com.

Whats the use of this?

Setting an email Reply-To means your Django web application can send emails from a valid email account. But all responses will be going to another valid email account. This comes in useful for things like contact forms using email.

So how do I set Reply-To in Django?

The easiest solutions is to make use of the class EmailMessage.


from django.core.mail import EmailMessage
email = EmailMessage('This is the subject', 'This is the body of your email', 'from@example.com',
        ['to@example.com',], headers = {'Reply-To': 'another@example.com'})
# send() sends the email
email.send()