comparison 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
comparison
equal deleted inserted replaced
4535:d67e33b9653e 4536:f2e6b303aa8a
5 import time, quopri, os, socket, smtplib, re, sys, traceback, email 5 import time, quopri, os, socket, smtplib, re, sys, traceback, email
6 6
7 from cStringIO import StringIO 7 from cStringIO import StringIO
8 8
9 from roundup import __version__ 9 from roundup import __version__
10 from roundup.date import get_timezone 10 from roundup.date import get_timezone, Date
11 11
12 from email.Utils import formatdate, formataddr, specialsre, escapesre 12 from email.Utils import formatdate, formataddr, specialsre, escapesre
13 from email.Message import Message 13 from email.Message import Message
14 from email.Header import Header 14 from email.Header import Header
15 from email.MIMEText import MIMEText 15 from email.MIMEText import MIMEText
205 """ 205 """
206 206
207 if not sender: 207 if not sender:
208 sender = self.config.ADMIN_EMAIL 208 sender = self.config.ADMIN_EMAIL
209 if self.debug: 209 if self.debug:
210 # don't send - just write to a file 210 # don't send - just write to a file, use unix from line so
211 open(self.debug, 'a').write('FROM: %s\nTO: %s\n%s\n' % 211 # that resulting file can be openened in a mailer
212 (sender, 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,
213 ', '.join(to), message)) 216 ', '.join(to), message))
214 else: 217 else:
215 # now try to send the message 218 # now try to send the message
216 try: 219 try:
217 # send the message as admin so bounces are sent there 220 # send the message as admin so bounces are sent there

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