##// END OF EJS Templates
mail response garden
marcink -
r1905:fbddaf2f beta
parent child Browse files
Show More
@@ -41,17 +41,20 from email.charset import Charset
41 41 from email.utils import parseaddr
42 42 from email.mime.base import MIMEBase
43 43
44 ADDRESS_HEADERS_WHITELIST = ['From', 'To', 'Delivered-To', 'Cc', 'Bcc']
44 ADDRESS_HEADERS_WHITELIST = ['From', 'To', 'Delivered-To', 'Cc']
45 45 DEFAULT_ENCODING = "utf-8"
46 46 VALUE_IS_EMAIL_ADDRESS = lambda v: '@' in v
47 47
48
48 49 def normalize_header(header):
49 50 return string.capwords(header.lower(), '-')
50 51
52
51 53 class EncodingError(Exception):
52 54 """Thrown when there is an encoding error."""
53 55 pass
54 56
57
55 58 class MailBase(object):
56 59 """MailBase is used as the basis of lamson.mail and contains the basics of
57 60 encoding an email. You actually can do all your email processing with this
@@ -105,7 +108,6 class MailBase(object):
105 108 {'filename': filename})
106 109 self.parts.append(part)
107 110
108
109 111 def attach_text(self, data, ctype):
110 112 """
111 113 This attaches a simpler text encoded part, which doesn't have a
@@ -124,6 +126,7 class MailBase(object):
124 126 for x in p.walk():
125 127 yield x
126 128
129
127 130 class MailResponse(object):
128 131 """
129 132 You are given MailResponse objects from the lamson.view methods, and
@@ -194,6 +197,7 class MailResponse(object):
194 197 'content_type': content_type,
195 198 'data': data,
196 199 'disposition': disposition,})
200
197 201 def attach_part(self, part):
198 202 """
199 203 Attaches a raw MailBase part from a MailRequest (or anywhere)
@@ -227,7 +231,6 class MailResponse(object):
227 231 del self.base.parts[:]
228 232 self.multipart = False
229 233
230
231 234 def update(self, message):
232 235 """
233 236 Used to easily set a bunch of heading from another dict
@@ -312,6 +315,7 class MailResponse(object):
312 315 def keys(self):
313 316 return self.base.keys()
314 317
318
315 319 def to_message(mail, separator="; "):
316 320 """
317 321 Given a MailBase message, this will construct a MIMEPart
@@ -382,7 +386,6 class MIMEPart(MIMEBase):
382 386
383 387 self.set_payload(encoded, charset=charset)
384 388
385
386 389 def extract_payload(self, mail):
387 390 if mail.body == None: return # only None, '' is still ok
388 391
General Comments 0
You need to be logged in to leave comments. Login now