Skip to content

Instantly share code, notes, and snippets.

@julian-klode
Created October 23, 2023 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julian-klode/91d2ddc81c150a5efdfeba9ba7fff5d5 to your computer and use it in GitHub Desktop.
Save julian-klode/91d2ddc81c150a5efdfeba9ba7fff5d5 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import email
import sys
import base64
preserve=["from", "subject", "date"]
msg = email.message_from_file(sys.stdin)
for key in msg:
if not key.lower() in preserve:
del msg[key]
msg.set_payload(base64.b64decode(msg.get_payload()))
sys.stdout.write(msg.as_string())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment