Opened 18 years ago

Closed 18 years ago

Last modified 18 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

Description

Hi,

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/mail.py
===================================================================
--- django/core/mail.py (revision 2694)
+++ django/core/mail.py (working copy)
@@ -3,6 +3,7 @@
 from django.conf import settings
 from email.MIMEText import MIMEText
 import smtplib
+import time

 class BadHeaderError(ValueError):
     pass
@@ -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')
         try:
             server.sendmail(from_email, recipient_list, msg.as_string())
             num_sent += 1

Attachments (1)

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

Download all attachments as: .zip

Change History (8)

comment:1 by Adrian Holovaty, 18 years ago

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

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

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

by eric@…, 18 years ago

Attachment: django_core_mail.diff added

Patch to add RFC 822 Date header to send_mail function

comment:4 by Adrian Holovaty, 18 years ago

Oooh, sailing in San Francisco!

comment:5 by Adrian Holovaty, 18 years ago

Resolution: fixed
Status: reopenedclosed

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

comment:6 by anonymous, 18 years ago

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

comment:7 by Adrian Holovaty, 18 years ago

milestone: Version 0.91

Milestone Version 0.91 deleted

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