Opened 7 years ago

Closed 7 years ago

#9214 closed (fixed)

Allow different `MAIL FROM` or `Return-Path` and `From` headers.

Reported by: mrmachine Owned by: nobody
Component: Core (Mail) Version: master
Severity: Keywords: EmailMessage Return-Path From
Cc: ross@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Currently, EmailMessage.message sets the From header to match the from_email argument in EmailMessage.__init__. This value is also passed as the from_addr argument to smtplib.SMTP.sendmail, which specifies the MAIL FROM or Return-Path header.

This makes it impossible to specify a MAIL FROM or Return-Path header that is different to the From header. This can be a requirement for VERP or other list / bounce management, and also makes it impossible to set a valid From header with multiple identities.

RFC2822 states that the From header specifies the author(s) of the message (those responsible for the writing of the message), who are not necessarily responsible for sending or delivery of the message. The MAIL FROM or Return-Path headers should refer to a single identity, who is responsible for the delivery of the message. This is where bounce messages will go.

I propose that the cleanest solution to this is to change the relevant line from EmailMessage.message to get the From header from self.extra_headers if it exists, and fallback to self.from_email as the default.

This should be entirely backwards compatible, and will allow users to override the From header either for bounce / list management, or to list multiple authors. Currently, if a From header is passed in the headers argument, the resulting message simply contains two From headers, which could yield unexpected results.

This change is important for anyone operating a mailing list, a subscription based email newsletter, or sending any email on behalf of their users or another 3rd party if they want to adhere to anti-SPAM requirements and best practices, e.g. SPF and Sender ID records, catching and removing subscribers who have sent bounce messages, etc.

Attachments (1)

9214-EmailMessage-r9084.diff (1.8 KB) - added by mrmachine 7 years ago.
Working patch with test.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by mrmachine

Working patch with test.

comment:1 Changed 7 years ago by mrmachine

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Version changed from 1.0 to SVN

comment:2 Changed 7 years ago by rossp

  • Cc ross@… added

comment:3 Changed 7 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

(In [9842]) Fixed #9214: EmailMessage now respects the From header instead of blindly using from_email. Thanks, Tai Lee.

Note: See TracTickets for help on using tickets.
Back to Top