Opened 7 years ago

Closed 21 months ago

#1412 closed defect (wontfix)

Add a "Date:" header to the mail

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

Description (last modified by coderanger)


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 
     39# line added by 
     40from time import tzname, timezone, daylight, altzone 
    3842from time import strftime, localtime, time 
     44# function added by 
     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 
     56# function added by 
     57def grg_timestamp(): 
     58  return strftime('%a, %d %b %Y %H:%M:%S ' + grg_tz_offset()) 
    4060if len(sys.argv) < 5: 
    4161    raise StandardError("Not enough arguments") 
    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 
     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 

Attachments (1) (1.3 KB) - added by grg 7 years ago.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by grg

comment:1 Changed 7 years ago by grg

The patch is not correctly displayed by the wiki, please see the file attached to this ticket.

comment:2 Changed 7 years ago by coderanger

  • Description modified (diff)

Fixing formatting.

comment:3 Changed 21 months ago by rjollos

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

This script is deprecated. Please take a look at the AnnouncerPlugin and WatchlistPlugin.

Add Comment

Modify Ticket

as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from athomas. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.