Opened 17 years ago

Last modified 12 years ago

#1412 closed defect

Add a "Date:" header to the mail — at Initial Version

Reported by: grg Owned by: Alec Thomas
Priority: normal Component: WikiNotifyScript
Severity: normal Keywords:
Cc: Trac Release: 0.10

Description

Hello,

I've installed trac-wiki-notify and one user reported that his mail client shows the date as follows:

Date: 12/31/69

This is because trac-wiki-notify does not add any Date: header, and some mail clients show a weird default date instead.

I've modified trac-wiki-notify to add the Date: header and would like to contribute this feature for further inclusion into the official version. Here is the patch:

--- trac-wiki-notify.orig Mon Apr 2 07:33:16 2007 +++ trac-wiki-notify Mon Apr 2 08:06:19 2007 @@ -35,8 +35,28 @@

import sys import smtplib import re

+ +# line added by grg@… +from time import tzname, timezone, daylight, altzone +

from time import strftime, localtime, time

+# function added by grg@… +def grg_tz_offset(): + lt = localtime() + if lt.tm_isdst > 0 and daylight: + tz = tzname[1] + utc_offset_minutes = - int(altzone/60) + else: + tz = tzname[0] + utc_offset_minutes = - int(timezone/60) + utc_offset_str = "%+03d%02d" % (utc_offset_minutes/60.0, utc_offset_minutes % 60) + return utc_offset_str + +# function added by grg@… +def grg_timestamp(): + return strftime('%a, %d %b %Y %H:%M:%S ' + grg_tz_offset()) +

if len(sys.argv) < 5:

raise StandardError("Not enough arguments")

@@ -82,6 +102,8 @@

for email in smtp_to:

smtp_body = "From: %s\n" % smtp_from smtp_body += "To: %s\n" % email

+ # line added by grg@… + smtp_body += "Date: %s\n" % grg_timestamp()

smtp_body += "Reply-To: %s\n" % smtp_from smtp_body += "Subject: Notification of %i changes to Trac Wiki %s\n\n" % (len(changes), trac_url) smtp_body += email_body

Change History (1)

Changed 17 years ago by grg

Note: See TracTickets for help on using tickets.