Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add "Reply To" to this in Django?

Tags:

python

django

msg = EmailMessage(subject, body, from_email, [to_email])
msg.content_subtype = "html"
msg.send()

How do I add the "reply to" header?

like image 963
TIMEX Avatar asked Mar 09 '11 09:03

TIMEX


2 Answers

You'll want to add a Reply-To header to the EmailMessage.

headers = {'Reply-To': reply_email}
msg = EmailMessage(subject, body, from_email, [to_email], headers=headers)
msg.content_subtype = "html"
msg.send()
like image 68
Sam Dolan Avatar answered Oct 02 '22 23:10

Sam Dolan


As of Django 1.8 there is an argument that can be passed into the constructor of EmailMessage named reply_to that will handle the headers logic for you.

like image 24
schillingt Avatar answered Oct 02 '22 23:10

schillingt