Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#1634 closed task (fixed)

[patch] core.mail does not include a Date header in mails

Reported by: Russell Cloran <russell@…> Owned by: adrian
Component: Validators Version: new-admin
Severity: blocker Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:



core.mail does not include a "Date" header, leading to mails which land up right at the bottom of my mailbox, which is a bit irritating :)

I can't think of any reason why anybody would want to generate an email without a Date header?

Index: django/core/
--- django/core/ (revision 2694)
+++ django/core/ (working copy)
@@ -3,6 +3,7 @@
 from django.conf import settings
 from email.MIMEText import MIMEText
 import smtplib
+import time

 class BadHeaderError(ValueError):
@@ -46,6 +47,7 @@
         msg['Subject'] = subject
         msg['From'] = from_email
         msg['To'] = ', '.join(recipient_list)
+        msg['Date'] = time.strftime('%a, %d %b %Y %H:%M:%S %z')
             server.sendmail(from_email, recipient_list, msg.as_string())
             num_sent += 1

Attachments (1)

django_core_mail.diff (672 bytes) - added by eric@… 10 years ago.
Patch to add RFC 822 Date header to send_mail function

Download all attachments as: .zip

Change History (8)

comment:1 Changed 10 years ago by adrian

Hmm, all the e-mails sent out by django.core.mail in my experience have *had* date headers. Is this something the e-mail server takes care of, and some servers don't do it? I believe I've always used sendmail.

comment:2 Changed 10 years ago by adrian

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

Closing for the reason outlined in the comment above. Please reopen if you have a good argument for adding Date headers.

comment:3 Changed 10 years ago by eric@…

  • priority changed from normal to low
  • Resolution worksforme deleted
  • Status changed from closed to reopened
  • Version changed from magic-removal to SVN

I get the same problem on debian sarge, python2.3.

Mail sent from my hosting provider's RHEL box does include a Date: header. I suspect the date header is being added by some systems but not others.

Adrian, won't you please help us poor sods who's systems don't add a date header by default?

I'll buy you a beer and/or take you sailing next time you are in San Francisco :)
(Ok, I'll do that whether you use this patch or not)

This approach uses the rfc822 module:

>>> import rfc822
>>> rfc822.formatdate()
'Thu, 25 May 2006 05:40:36 GMT'

See attached patch file

Changed 10 years ago by eric@…

Patch to add RFC 822 Date header to send_mail function

comment:4 Changed 10 years ago by adrian

Oooh, sailing in San Francisco!

comment:5 Changed 10 years ago by adrian

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

(In [2984]) Fixed #1634 -- Changed django.core.mail to include 'Date' header in e-mails. Thanks, Eric Walstad

comment:6 Changed 9 years ago by anonymous

  • Component changed from Core framework to Validators
  • milestone set to Version 0.91
  • priority changed from low to high
  • Severity changed from normal to blocker
  • Type changed from defect to task
  • Version changed from SVN to new-admin

comment:7 Changed 9 years ago by adrian

  • milestone Version 0.91 deleted

Milestone Version 0.91 deleted

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