Opened 13 months ago
Closed 13 months ago
#34904 closed Bug (fixed)
Changing email object after sending mutates mail in mail.outbox
Reported by: | CheesyPhoenix | Owned by: | CheesyPhoenix |
---|---|---|---|
Component: | Core (Mail) | Version: | dev |
Severity: | Normal | Keywords: | mail.outbox locmem testing |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
When testing emails using the locmem email backend with mail.outbox, modifying an email object after calling .send()
also modifies the email object in django.core.mail.outbox
. This leads to inconsistencies between test and production environments, where an email modified in production after calling .send()
will not be changed since it has already been sent.
Steps to reproduce:
- Run this test in any django project:
def test_mutate_after_send(self) -> None: email = EmailMessage( subject="correct subject", body="test body", from_email="from@example.com", to=["to@example.com"], ) email.send() email.subject = "incorrect subject" self.assertEqual("correct subject", mail.outbox[0].subject)
GitHub PR fixing the issue: https://github.com/django/django/pull/17377
Change History (4)
comment:1 by , 13 months ago
Description: | modified (diff) |
---|
comment:2 by , 13 months ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 13 months ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
Thanks for the report.