Mercurial > p > roundup > code
comparison roundup/mailer.py @ 1981:ce6806a2a72d
add roundup version to mailer headers
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 20 Jan 2004 00:05:46 +0000 |
| parents | 4ac11e7fa11a |
| children | fc52d57c6c3e |
comparison
equal
deleted
inserted
replaced
| 1980:8a6077ec701b | 1981:ce6806a2a72d |
|---|---|
| 1 """Sending Roundup-specific mail over SMTP.""" | 1 """Sending Roundup-specific mail over SMTP.""" |
| 2 # $Id: mailer.py,v 1.3 2003-10-04 11:21:47 jlgijsbers Exp $ | 2 # $Id: mailer.py,v 1.4 2004-01-20 00:05:46 richard Exp $ |
| 3 | 3 |
| 4 import time, quopri, os, socket, smtplib, re | 4 import time, quopri, os, socket, smtplib, re |
| 5 | 5 |
| 6 from cStringIO import StringIO | 6 from cStringIO import StringIO |
| 7 from MimeWriter import MimeWriter | 7 from MimeWriter import MimeWriter |
| 8 | 8 |
| 9 from roundup.rfc2822 import encode_header | 9 from roundup.rfc2822 import encode_header |
| 10 from roundup import __version__ | |
| 10 | 11 |
| 11 class MessageSendError(RuntimeError): | 12 class MessageSendError(RuntimeError): |
| 12 pass | 13 pass |
| 13 | 14 |
| 14 class Mailer: | 15 class Mailer: |
| 34 | 35 |
| 35 # Add a unique Roundup header to help filtering | 36 # Add a unique Roundup header to help filtering |
| 36 writer.addheader('X-Roundup-Name', self.config.TRACKER_NAME) | 37 writer.addheader('X-Roundup-Name', self.config.TRACKER_NAME) |
| 37 # and another one to avoid loops | 38 # and another one to avoid loops |
| 38 writer.addheader('X-Roundup-Loop', 'hello') | 39 writer.addheader('X-Roundup-Loop', 'hello') |
| 40 # finally, an aid to debugging problems | |
| 41 writer.addheader('X-Roundup-Version', __version__) | |
| 39 | 42 |
| 40 writer.addheader('MIME-Version', '1.0') | 43 writer.addheader('MIME-Version', '1.0') |
| 41 | 44 |
| 42 return message, writer | 45 return message, writer |
| 43 | 46 |
| 56 body = writer.startbody('text/plain; charset=utf-8') | 59 body = writer.startbody('text/plain; charset=utf-8') |
| 57 content = StringIO(content) | 60 content = StringIO(content) |
| 58 quopri.encode(content, body, 0) | 61 quopri.encode(content, body, 0) |
| 59 | 62 |
| 60 self.smtp_send(to, message) | 63 self.smtp_send(to, message) |
| 61 | 64 |
| 62 def bounce_message(self, bounced_message, to, error, | 65 def bounce_message(self, bounced_message, to, error, |
| 63 subject='Failed issue tracker submission'): | 66 subject='Failed issue tracker submission'): |
| 64 """Bounce a message, attaching the failed submission. | 67 """Bounce a message, attaching the failed submission. |
| 65 | 68 |
| 66 Arguments: | 69 Arguments: |
