From f2228172dcbed77780ef7b60b10ac3e85cded918 Mon Sep 17 00:00:00 2001 From: schlatterbeck Date: Wed, 28 Sep 2011 15:50:20 +0000 Subject: [PATCH] When debugging mail (debug = 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. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4649 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/mailer.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/roundup/mailer.py b/roundup/mailer.py index d44568e..a91baf2 100644 --- a/roundup/mailer.py +++ b/roundup/mailer.py @@ -7,7 +7,7 @@ import time, quopri, os, socket, smtplib, re, sys, traceback, email 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 @@ class Mailer: 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 -- 2.30.2