The test email backend (locmem) should perform more validation of messages
|Reported by:||brutasse||Owned by:||nobody|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Currently the locmem email backend only stores EmailMessage instances on mail.outbox, and does not perform as much validation as other backends.
In particular, calling .message() on an EmailMessage instance creates a SafeMIMEText object which forbids multiline headers. All email backends call .message() except for the locmem backend. This is a opportunity for deployment surprises where sending an email would work during the tests but not in production if the subject is constructed using a template that has an EOL marker at the end of the file.
The attached patch naively calls .message() on each outgoing message to trigger this validation. This should be backwards-compatible since that error would be raised anyways when sending emails with a proper backend.
An alternative solution to this issue (email subjects ending with a newline) could be to strip all headers but this is a more intrusive change.
Change History (6)
Changed 20 months ago by brutasse
comment:1 Changed 20 months ago by brutasse
- Has patch set
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset