comparison roundup/mailer.py @ 3532:f43424d545a6

fix timezone offsetting in email Date: header
author Richard Jones <richard@users.sourceforge.net>
date Thu, 02 Feb 2006 04:14:29 +0000
parents fe75b55fc49d
children 61d48244e7a8
comparison
equal deleted inserted replaced
3531:616244e247f4 3532:f43424d545a6
1 """Sending Roundup-specific mail over SMTP. 1 """Sending Roundup-specific mail over SMTP.
2 """ 2 """
3 __docformat__ = 'restructuredtext' 3 __docformat__ = 'restructuredtext'
4 # $Id: mailer.py,v 1.13 2006-01-27 02:41:18 richard Exp $ 4 # $Id: mailer.py,v 1.14 2006-02-02 04:14:29 richard Exp $
5 5
6 import time, quopri, os, socket, smtplib, re 6 import time, quopri, os, socket, smtplib, re
7 7
8 from cStringIO import StringIO 8 from cStringIO import StringIO
9 from MimeWriter import MimeWriter 9 from MimeWriter import MimeWriter
12 from roundup import __version__ 12 from roundup import __version__
13 13
14 try: 14 try:
15 from email.Utils import formatdate 15 from email.Utils import formatdate
16 except ImportError: 16 except ImportError:
17 def formatdate(timeval): 17 def formatdate():
18 return time.strftime("%a, %d %b %Y %H:%M:%S +0000", timeval) 18 return time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())
19 19
20 class MessageSendError(RuntimeError): 20 class MessageSendError(RuntimeError):
21 pass 21 pass
22 22
23 class Mailer: 23 class Mailer:
58 message = StringIO() 58 message = StringIO()
59 writer = MimeWriter(message) 59 writer = MimeWriter(message)
60 writer.addheader('Subject', encode_header(subject, charset)) 60 writer.addheader('Subject', encode_header(subject, charset))
61 writer.addheader('To', ', '.join(to)) 61 writer.addheader('To', ', '.join(to))
62 writer.addheader('From', author) 62 writer.addheader('From', author)
63 writer.addheader('Date', formatdate(time.mktime(time.gmtime()))) 63 writer.addheader('Date', formatdate())
64 64
65 # Add a unique Roundup header to help filtering 65 # Add a unique Roundup header to help filtering
66 writer.addheader('X-Roundup-Name', encode_header(tracker_name, 66 writer.addheader('X-Roundup-Name', encode_header(tracker_name,
67 charset)) 67 charset))
68 # and another one to avoid loops 68 # and another one to avoid loops

Roundup Issue Tracker: http://roundup-tracker.org/