File tree Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Original file line number Diff line number Diff line change 1
1
from django .contrib import admin
2
2
3
3
from email .parser import Parser
4
+ from email import policy
4
5
5
6
from .models import QueuedMail
6
7
@@ -13,18 +14,9 @@ def parsed_content(self, obj):
13
14
# We only try to parse the *first* piece, because we assume
14
15
# all our emails are trivial.
15
16
try :
16
- parser = Parser ()
17
+ parser = Parser (policy = policy . default )
17
18
msg = parser .parsestr (obj .fullmsg )
18
- b = msg .get_payload (decode = True )
19
- if b :
20
- return b .decode ('utf8' )
21
-
22
- pl = msg .get_payload ()
23
- for p in pl :
24
- b = p .get_payload (decode = True )
25
- if b :
26
- return b .decode ('utf8' )
27
- return "Could not find body"
19
+ return msg .get_body (preferencelist = ('plain' , )).get_payload (decode = True ).decode ('utf8' )
28
20
except Exception as e :
29
21
return "Failed to get body: %s" % e
30
22
You can’t perform that action at this time.
0 commit comments