Opened 17 years ago

Last modified 12 years ago

#1412 closed defect

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

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

Description (last modified by Noah Kantrowitz)

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

    old new  
    3535import sys
    3636import smtplib
    3737import re
     38
     39# line added by grg@openwall.com
     40from time import tzname, timezone, daylight, altzone
     41
    3842from time import strftime, localtime, time
    3943
     44# function added by grg@openwall.com
     45def grg_tz_offset():
     46  lt = localtime()
     47  if lt.tm_isdst > 0 and daylight:
     48      tz = tzname[1]
     49      utc_offset_minutes = - int(altzone/60)
     50  else:
     51      tz = tzname[0]
     52      utc_offset_minutes = - int(timezone/60)
     53  utc_offset_str = "%+03d%02d" % (utc_offset_minutes/60.0, utc_offset_minutes % 60)
     54  return utc_offset_str
     55
     56# function added by grg@openwall.com
     57def grg_timestamp():
     58  return strftime('%a, %d %b %Y %H:%M:%S ' + grg_tz_offset())
     59
    4060if len(sys.argv) < 5:
    4161    raise StandardError("Not enough arguments")
    4262
     
    82102        for email in smtp_to:
    83103            smtp_body = "From: %s\n" % smtp_from
    84104            smtp_body += "To: %s\n" % email
     105            # line added by grg@openwall.com
     106            smtp_body += "Date: %s\n" % grg_timestamp()
    85107            smtp_body += "Reply-To: %s\n" % smtp_from
    86108            smtp_body += "Subject: Notification of %i changes to Trac Wiki %s\n\n" % (len(changes), trac_url)
    87109            smtp_body += email_body

Change History (3)

Changed 17 years ago by grg

comment:1 Changed 17 years ago by grg

The patch is not correctly displayed by the wiki, please see the file trac-wiki-notify.header.date.diff attached to this ticket.

comment:2 Changed 17 years ago by Noah Kantrowitz

Description: modified (diff)

Fixing formatting.

Note: See TracTickets for help on using tickets.