[Fixed]-Emails, a different 'reply to' address than sender address

15👍

There are in fact standardized headers to specify response headers: http://cr.yp.to/immhf/response.html.

As far as implementing this in Django is concerned, the documentation contains an example:

from django.core.mail import EmailMessage

email = EmailMessage(
    'Hello', # email subject
    'Body goes here', # email body
    'from@example.com', # sender address
    ['to1@example.com', 'to2@example.com'],
    ['bcc@example.com'],
    headers={'Reply-To': 'another@example.com'},
)

This solved my problem.

4👍

Reply-To is a standard SMTP header.

I can’t find a good reference for it at the moment, but it is mentioned in the Wikipedia article on Email.

Edit: Found it: RFC 5322, section 3.6.2

2👍

The RFC says you can specify multiple emails and that is what I was looking for. Came up with this:

from django.core.mail import EmailMessage
headers = {'Reply-To': 'email@one.com;email@two.com'}
msg = EmailMessage(subject, html_content, EMAIL_HOST_USER, email_list, headers=headers)
msg.content_subtype = "html"
msg.send()

Works like a charm. Note: EMAIL_HOST_USER is imported from your settings file as per Django doc email setup. More on this here, search for ‘reply-to’: https://docs.djangoproject.com/en/dev/topics/email/

👤radtek

0👍

Here is also how reply-to can be used

from django.core.mail import EmailMessage

email = EmailMessage(
    'Hello',
    'Body goes here',
    'from@example.com',
    ['to1@example.com', 'to2@example.com'],
    ['bcc@example.com'],
    reply_to=['another@example.com'],
    headers={'Message-ID': 'foo'},
)

Read more at docs docs.djangoproject

Leave a comment