diff options
author | Quentin <quentin@dufour.io> | 2024-01-08 10:39:26 +0000 |
---|---|---|
committer | Quentin <quentin@dufour.io> | 2024-01-08 10:39:26 +0000 |
commit | d7788e29a8a64550e9b274001ff3fb9a7bf3473b (patch) | |
tree | e43a11753472f1917ce4aa6ddba24ae3a513bd50 /tests | |
parent | 152d5b7604337fe19a7aea7fc37b3d4615ca7393 (diff) | |
parent | 42a54b2c500294c594f3efdd25db28c18f5ac238 (diff) | |
download | aerogramme-d7788e29a8a64550e9b274001ff3fb9a7bf3473b.tar.gz aerogramme-d7788e29a8a64550e9b274001ff3fb9a7bf3473b.zip |
Merge pull request 'Implement search' (#61) from feat/search into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/aerogramme/pulls/61
Diffstat (limited to 'tests')
-rw-r--r-- | tests/instrumentation/mbox-to-imap.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/instrumentation/mbox-to-imap.py b/tests/instrumentation/mbox-to-imap.py new file mode 100644 index 0000000..79e8b41 --- /dev/null +++ b/tests/instrumentation/mbox-to-imap.py @@ -0,0 +1,39 @@ +from imaplib import IMAP4_SSL, IMAP4 +from os import listdir +from os.path import isfile, join +import sys +import argparse +import mailbox + +parser = argparse.ArgumentParser( + prog='mbox-to-imap', + description='Send an mbox to an imap server', + epilog='Just a debug tool') +parser.add_argument('mbox_path') # positional argument +parser.add_argument('-H', '--host', default="localhost") +parser.add_argument('-p', '--port', default="143") +parser.add_argument('-u', '--user') +parser.add_argument('-s', '--password') +parser.add_argument('-m', '--mailbox', default="INBOX") +parser.add_argument('-t', '--tls', action='store_true') +args = parser.parse_args() + +mbox = mailbox.mbox(args.mbox_path) + +if args.tls: + imap = IMAP4_SSL +else: + imap = IMAP4 + + +print(args) +with imap(host=args.host, port=args.port) as M: + print(M.login(args.user, args.password)) + print(M.select(args.mailbox)) + for k in mbox.keys(): + content = mbox.get(k).as_bytes() + M.append(args.mailbox, [], None, content) + print(f"{k}/{len(mbox)}") + + + |