Opened 13 years ago

Closed 13 years ago

Last modified 12 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 Holovaty
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: no UI/UX: no



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@… 13 years ago.
Patch to add RFC 822 Date header to send_mail function

Download all attachments as: .zip

Change History (8)

comment:1 Changed 13 years ago by Adrian Holovaty

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 13 years ago by Adrian Holovaty

Resolution: worksforme
Status: newclosed

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

comment:3 Changed 13 years ago by eric@…

priority: normallow
Resolution: worksforme
Status: closedreopened
Version: magic-removalSVN

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 13 years ago by eric@…

Attachment: django_core_mail.diff added

Patch to add RFC 822 Date header to send_mail function

comment:4 Changed 13 years ago by Adrian Holovaty

Oooh, sailing in San Francisco!

comment:5 Changed 13 years ago by Adrian Holovaty

Resolution: fixed
Status: reopenedclosed

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

comment:6 Changed 13 years ago by anonymous

Component: Core frameworkValidators
milestone: Version 0.91
priority: lowhigh
Severity: normalblocker
Type: defecttask
Version: SVNnew-admin

comment:7 Changed 12 years ago by Adrian Holovaty

milestone: Version 0.91

Milestone Version 0.91 deleted

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