diff roundup/mailer.py @ 4536:f2e6b303aa8a

When debugging mail (debug = <filename> setting in [mail] section... ...of config.ini) write header for unix mailbox format so that resulting debug file can be opened with a standard mailer.
author Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
date Wed, 28 Sep 2011 15:50:20 +0000
parents 7f67092fe03d
children 62239a524beb
line wrap: on
line diff
--- a/roundup/mailer.py	Wed Sep 28 11:59:08 2011 +0000
+++ b/roundup/mailer.py	Wed Sep 28 15:50:20 2011 +0000
@@ -7,7 +7,7 @@
 from cStringIO import StringIO
 
 from roundup import __version__
-from roundup.date import get_timezone
+from roundup.date import get_timezone, Date
 
 from email.Utils import formatdate, formataddr, specialsre, escapesre
 from email.Message import Message
@@ -207,9 +207,12 @@
         if not sender:
             sender = self.config.ADMIN_EMAIL
         if self.debug:
-            # don't send - just write to a file
-            open(self.debug, 'a').write('FROM: %s\nTO: %s\n%s\n' %
-                                        (sender,
+            # don't send - just write to a file, use unix from line so
+            # that resulting file can be openened in a mailer
+            fmt = '%a %b %m %H:%M:%S %Y'
+            unixfrm = 'From %s %s' % (sender, Date ('.').pretty (fmt))
+            open(self.debug, 'a').write('%s\nFROM: %s\nTO: %s\n%s\n\n' %
+                                        (unixfrm, sender,
                                          ', '.join(to), message))
         else:
             # now try to send the message

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