summaryrefslogtreecommitdiff
path: root/imap-tool
diff options
context:
space:
mode:
Diffstat (limited to 'imap-tool')
-rwxr-xr-ximap-tool30
1 files changed, 15 insertions, 15 deletions
diff --git a/imap-tool b/imap-tool
index 455e009..0fbc169 100755
--- a/imap-tool
+++ b/imap-tool
@@ -11,11 +11,11 @@ from enum import Enum
class imap_action(Enum):
MAILBOX_LIST = 1
MAILBOX_LIST_SUB = 2
- MAILBOX_CREATE = 3
- MAILBOX_DELETE = 4
- MAILBOX_SUBSCRIBE = 5
- MAILBOX_UNSUBSCRIBE = 6
- MAILBOX_STATS = 7
+ MAILBOX_STATS = 3
+ MAILBOX_CREATE = 4
+ MAILBOX_DELETE = 5
+ MAILBOX_SUBSCRIBE = 6
+ MAILBOX_UNSUBSCRIBE = 7
MAILBOX_RENAME = 8
MAILBOX_ARCHIVE = 9
@@ -40,13 +40,13 @@ class imap_tool():
"Actions:\n" \
" mailbox-list\n" \
" mailbox-list-sub\n" \
+ " mailbox-stats [mailbox]" \
" mailbox-create [mailbox]\n" \
" mailbox-delete [mailbox]\n" \
" mailbox-subscribe [mailbox]\n" \
" mailbox-unsubscribe [mailbox]\n" \
" mailbox-rename [mailbox] [mailbox]\n" \
- " mailbox-archive [mailbox] [year]\n" \
- " mailbox-stats"
+ " mailbox-archive [mailbox] [year]\n"
def error_decode(self, data):
return data[0].decode()
@@ -88,6 +88,14 @@ class imap_tool():
for entry in data:
name = entry.decode().split(" ")[-1]
print("- " + name)
+ elif self.action == imap_action.MAILBOX_STATS:
+ ret, data = imap.examine(self.mailbox)
+ if ret != "OK":
+ print("Error getting stats for mailbox " + self.mailbox)
+ raise Exception()
+
+ count = int(data[0])
+ print("Mailbox " + self.mailbox + " has " + str(count) + " entries")
elif self.action == imap_action.MAILBOX_CREATE:
ret, data = imap.create(self.mailbox)
if ret != "OK":
@@ -116,14 +124,6 @@ class imap_tool():
raise Exception()
print("Unsubscribed from mailbox " + self.mailbox)
- elif self.action == imap_action.MAILBOX_STATS:
- ret, data = imap.examine(self.mailbox)
- if ret != "OK":
- print("Error getting stats for mailbox " + self.mailbox)
- raise Exception()
-
- count = int(data[0])
- print("Mailbox " + self.mailbox + " has " + str(count) + " entries")
elif self.action == imap_action.MAILBOX_RENAME:
ret, data = imap.rename(self.mailbox[0], self.mailbox[1])
if ret != "OK":