Method for allowing different `MAIL FROM` or `Return-Path` and `From` headers.

55 views
Skip to first unread message

Ian Campbell

unread,
Feb 7, 2018, 12:35:06 PM2/7/18
to Django developers (Contributions to Django itself)
Hi - I have a question about an issue I've recently run into with Django. It relates to creating a separate `Return Path` and `From` header in an email using Django.

The current solution is undocumented, but discussed here: https://code.djangoproject.com/ticket/9214

To create a separate `Return Path` and `From` header in an email, one puts the `Return Path` in the `from_email` parameter, and creates a separate `From` header in the `headers` parameter. The current Django code can be seen here: https://github.com/django/django/blob/a38ae914d89809aed6d79337b74a8b31b6d3849a/django/core/mail/message.py#L256

My question is around the fact that this seems to be a bit of a hack. Does it make more sense to create a PR to document this "feature" in the docs, or would it make more sense to create a PR to deprecate the old way of doing things in favor of a separate from_email and return_path parameter? Or something else?

I'd love to contribute one or the other, to save others time in having to dig through and find a nine year old ticket to figure out how to set the `Return Path` parameter. I thought to post here before creating an issue in the Issue Tracker because I'm not sure whether the current implementation would be considered best practice or not. Thanks for any suggestions!

Carlton Gibson

unread,
Feb 8, 2018, 3:44:20 AM2/8/18
to Django developers (Contributions to Django itself)
Hi Ian, 

As you describe it here, this sounds quite reasonable. It seems worth a Trac ticket. 

* We need `Return Path` because ...
* Currently possible but ...
* Either document or add new `return_path` parameter. 

My initial thought is that a `Note` block in the docs explaining the approach from the original ticket may be enough here. 

Kind Regards,

Carlton



Reply all
Reply to author
Forward
0 new messages