Skip to content

Commit 2869884

Browse files
author
Ralf Schlatterbeck
committed
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.
1 parent 150de0e commit 2869884

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

roundup/mailer.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from cStringIO import StringIO
88

99
from roundup import __version__
10-
from roundup.date import get_timezone
10+
from roundup.date import get_timezone, Date
1111

1212
from email.Utils import formatdate, formataddr, specialsre, escapesre
1313
from email.Message import Message
@@ -207,9 +207,12 @@ def smtp_send(self, to, message, sender=None):
207207
if not sender:
208208
sender = self.config.ADMIN_EMAIL
209209
if self.debug:
210-
# don't send - just write to a file
211-
open(self.debug, 'a').write('FROM: %s\nTO: %s\n%s\n' %
212-
(sender,
210+
# don't send - just write to a file, use unix from line so
211+
# that resulting file can be openened in a mailer
212+
fmt = '%a %b %m %H:%M:%S %Y'
213+
unixfrm = 'From %s %s' % (sender, Date ('.').pretty (fmt))
214+
open(self.debug, 'a').write('%s\nFROM: %s\nTO: %s\n%s\n\n' %
215+
(unixfrm, sender,
213216
', '.join(to), message))
214217
else:
215218
# now try to send the message

0 commit comments

Comments
 (0)