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':'[email protected]'}

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 ([email protected]) but the reply-to address maybe to an admin ([email protected]); this will mean if you choose to reply to the message from [email protected] you will be sending an email to [email protected]

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', '[email protected]',
        ['[email protected]',], headers = {'Reply-To': '[email protected]'})
# send() sends the email