#35365: Add RFC 3834 Auto-Submitted header to emails by default ---------------------------------+------------------------------------ Reporter: Tobias Bengfort | Owner: cgracin Type: New feature | Status: assigned Component: Core (Mail) | Version: dev Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 1 Easy pickings: 0 | UI/UX: 0 ---------------------------------+------------------------------------ Changes (by Mike Edmunds):
* cc: Mike Edmunds (added) Comment: [[https://github.com/anymail/django-anymail django-anymail] maintainer here] This will break sending for many users working with an Email Service Provider. Most ESPs restrict the headers that can be used. Some will silently strip headers they don't allow, but others will reject the message entirely. (The restrictions are sometimes different for the ESP's SMTP endpoint vs. their HTTP API. A few ESPs don't allow ''any'' extra headers.) I would suggest, instead, documenting how users can set this header themselves when sending a message. For users who want it on all messages, one option is a "wrapper" email backend that adds the header: {{{#!python # Add this to your project, and in settings.py set: # EMAIL_BACKEND="path.to.this.file.AutoSubmittedSMTPBackend" class AutoSubmittedSMTPBackend(django.core.mail.backends.smtp.EmailBackend): def send_messages(messages): for message in messages: message.extra_headers.setdefault("Auto-Submitted", "auto- generated") return super().send_messages(messages) }}} Long term, allowing configurable defaults for each email backend could simplify this. Looks like #35514 is starting down that path. FWIW, django-anymail email backends [https://anymail.dev/en/stable/sending/anymail_additions/#send-defaults, already support defaults]. If you're using an Anymail backend (with an ESP that allows this header), you can use: {{{#!python # settings.py ANYMAIL = { ..., "SEND_DEFAULTS": { "extra_headers": { "Auto-Submitted": "auto-generated", }, }, } }}} -- Ticket URL: <https://code.djangoproject.com/ticket/35365#comment:13> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/0107019046a680bf-905c9571-41de-4104-838f-55c1986bfb4e-000000%40eu-central-1.amazonses.com.