Search code examples
djangoemailcontact-form

Emails, a different 'reply to' address than sender address


I have a contact form on a website (a general form: name, email, subject, message) in which mails are sent using google apps smtp to the admins.
Currently if an administrator wants to reply to the mail directly selecting the reply option, the person's reply's To field will be filled by the sender's address automatically.

What I wan't to ask is, Is there any standardized way to pass on some additional info with the mail which would define any reply to the mail should go to this address instead of the sender's?

It does seems that there is a little chance for this option as it may lead to some problems due to spammers (They may define a custom reply field in their mail and a general user might not look where they are replying).

So as an alternative what I thought is to find a way to create a filter with sender's account which figures out the reply email address from the format and forwards the mail (Doesn't seems like a good solution and I have no idea how to achieve this).

I have tagged django, though this is not directly related with this, as I will finally implement this through django.


Solution

  • 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
        '[email protected]', # sender address
        ['[email protected]', '[email protected]'],
        ['[email protected]'],
        headers={'Reply-To': '[email protected]'},
    )
    

    This solved my problem.