aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2021-03-09 00:04:25 +0100
committerTeddy Wing2021-03-09 00:04:25 +0100
commit34f470d2fbfff09a448a54f60addb385db6aa036 (patch)
treef03ea2dd78cc87ab1ba695b38dd342e6db8a3a63
parentae1335c69ca2aa111b80690c2024e0053609f52e (diff)
downloadmutt-ottolangy-34f470d2fbfff09a448a54f60addb385db6aa036.tar.bz2
Try extracting the body of an email message
-rw-r--r--mail.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/mail.py b/mail.py
new file mode 100644
index 0000000..e3a10ae
--- /dev/null
+++ b/mail.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+
+# from email import parser
+import email
+import sys
+
+# p = parser.BytesFeedParser()
+# p.feed(sys.stdin)
+# msg = p.close()
+
+with open('en-mail', 'r') as f:
+ msg = email.message_from_file(f)
+
+ # print(msg.items())
+ # print(msg.get_body())
+ # print(type(msg))
+ # for p in msg.iter_parts():
+ # print(p)
+
+ for p in msg.walk():
+ print(p.get_content_type())
+
+ if p.get_content_type() == 'text/plain':
+ print(dir(p))
+ print(p.get_payload())