Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #35365 -- Add RFC 3824 Auto-Submitted header to emails by default #18099

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cgracin
Copy link

@cgracin cgracin commented Apr 23, 2024

Implemented the default behaviour of attaching Auto-Submitted : auto-generated header to emails by default. Created subclass of EmailMessage that allows users to opt-out of this default. Added unit tests for this added functionality.

Trac ticket number

ticket-35365

Branch description

RFC 3824 (​https://www.rfc-editor.org/rfc/rfc3834) defines the Auto-Submitted header for emails to avoid mail loops. Based on this, the EmailMessage class now attaches a default header of "Auto-Submitted : auto-generated" to emails. The user can opt-out of this default by using the NoAutoSubmittedHeaderEmailMessage subclass. This will remove the "Auto-Submitted : auto-generated" header.

Checklist

  • This PR targets the main branch.
  • The commit message is written in past tense, mentions the ticket number, and ends with a period.
  • I have checked the "Has patch" ticket flag in the Trac system.
  • I have added or updated relevant tests.
  • I have added or updated relevant docs, including release notes if applicable.
  • For UI changes, I have attached screenshots in both light and dark modes.

Implemented the default behaviour of attaching Auto-Submitted : auto-generated
header to emails by default. Created subclass of EmailMessage that
allows users to opt-out of this default. Added unit tests for
this added functionality.
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! Thank you for your contribution 💪

As it's your first contribution be sure to check out the patch review checklist.

If you're fixing a ticket from Trac make sure to set the "Has patch" flag and include a link to this PR in the ticket!

If you have any design or process questions then you can ask in the Django forum.

Welcome aboard ⛵️!

@@ -280,9 +280,15 @@ def message(self):
if "message-id" not in header_names:
# Use cached DNS_NAME for performance
msg["Message-ID"] = make_msgid(domain=DNS_NAME)

if "Auto-Submitted" not in self.extra_headers:
# Default to adding the Auto-Submitted : auto-generated header
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should not be a space after "Auth-Submitted" (also in other places).

Copy link
Contributor

@shangxiao shangxiao Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I'd ask this comment be removed pls. We have a policy of not commenting the "what", rather focusing on commenting the "why" 👍

@@ -193,7 +193,9 @@ Decorators
Email
~~~~~

* ...
* :class:`<django.core.mail.EmailMessage>` now attaches a default header of "Auto-Submitted : auto-generated"
to outgoing emails. You can opt-out of this by using :class:`<django.core.mail.NoAutoSubmittedHeaderEmailMessage>`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The angle brackets are not required and should be removed.

Implemented the default behaviour of attaching Auto-Submitted: auto-generated
header to emails by default. Created subclass of EmailMessage that
allows users to opt-out of this default. Added unit tests for
this added functionality.
@cgracin
Copy link
Author

cgracin commented Apr 26, 2024

This is just minor syntax fixes for previous comments. I am going to implement the changes mentioned in the Trac Ticket thread in the next iteration of the PR.

Implemented the default behaviour of attaching Auto-Submitted : auto-generated
header to emails by default. Created subclass of EmailMessage that
allows users to opt-out of this default. Added unit tests for
this added functionality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants