comparison roundup/mailer.py @ 3464:75b4c2c32cf3

fix Date: header generation to be LOCALE-agnostic [SF#1352624]
author Richard Jones <richard@users.sourceforge.net>
date Fri, 13 Jan 2006 02:38:45 +0000
parents e49e6c7b14fb
children db856d488de0
comparison
equal deleted inserted replaced
3463:da8fe3566f67 3464:75b4c2c32cf3
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.10 2004-07-25 15:25:44 a1s Exp $ 4 # $Id: mailer.py,v 1.11 2006-01-13 02:38:45 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
10 10
11 from roundup.rfc2822 import encode_header 11 from roundup.rfc2822 import encode_header
12 from roundup import __version__ 12 from roundup import __version__
13
14 try:
15 from email.Utils import formatdate
16 except ImportError:
17 def formatdate(timeval):
18 return time.strftime("%a, %d %b %Y %H:%M:%S +0000", timeval)
13 19
14 class MessageSendError(RuntimeError): 20 class MessageSendError(RuntimeError):
15 pass 21 pass
16 22
17 class Mailer: 23 class Mailer:
52 message = StringIO() 58 message = StringIO()
53 writer = MimeWriter(message) 59 writer = MimeWriter(message)
54 writer.addheader('Subject', encode_header(subject, charset)) 60 writer.addheader('Subject', encode_header(subject, charset))
55 writer.addheader('To', ', '.join(to)) 61 writer.addheader('To', ', '.join(to))
56 writer.addheader('From', author) 62 writer.addheader('From', author)
57 writer.addheader('Date', time.strftime("%a, %d %b %Y %H:%M:%S +0000", 63 writer.addheader('Date', formatdate(time.gmtime()))
58 time.gmtime()))
59 64
60 # Add a unique Roundup header to help filtering 65 # Add a unique Roundup header to help filtering
61 writer.addheader('X-Roundup-Name', encode_header(tracker_name, 66 writer.addheader('X-Roundup-Name', encode_header(tracker_name,
62 charset)) 67 charset))
63 # and another one to avoid loops 68 # and another one to avoid loops

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