Skip to content

Instantly share code, notes, and snippets.

@stevecooperorg
Created May 15, 2023 11:45
Show Gist options
  • Save stevecooperorg/856a10c3819127377ae7cf17ae3a1622 to your computer and use it in GitHub Desktop.
Save stevecooperorg/856a10c3819127377ae7cf17ae3a1622 to your computer and use it in GitHub Desktop.
import mailbox
def extract_from(mbox_file):
mbox = mailbox.mbox(mbox_file)
for message in mbox:
print(message['from'])
if __name__ == "__main__":
import sys
if len(sys.argv) != 2:
print(f"Usage: {sys.argv[0]} MBOX_FILE")
else:
extract_from(sys.argv[1])
# use like python extract_from.py path_to_your_mbox_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment