Benjamin Renard commited on 2013-12-04 09:39:41
Showing 1 changed files, with 14 additions and 1 deletions.
| ... | ... |
@@ -91,6 +91,13 @@ parser.add_option('-v',
|
| 91 | 91 |
action="store_true", |
| 92 | 92 |
dest="verbose") |
| 93 | 93 |
|
| 94 |
+parser.add_option('-l',
|
|
| 95 |
+ '--list', |
|
| 96 |
+ action="store_true", |
|
| 97 |
+ dest="list", |
|
| 98 |
+ help="List mailboxes", |
|
| 99 |
+ default=False) |
|
| 100 |
+ |
|
| 94 | 101 |
(options, args) = parser.parse_args() |
| 95 | 102 |
|
| 96 | 103 |
if options.verbose: |
| ... | ... |
@@ -141,14 +148,20 @@ if options.user: |
| 141 | 148 |
sys.exit(3) |
| 142 | 149 |
|
| 143 | 150 |
try: |
| 151 |
+ if options.list: |
|
| 152 |
+ logging.info('List mailbox')
|
|
| 153 |
+ (status,l) = server.list() |
|
| 154 |
+ for d in l: |
|
| 155 |
+ logging.info(' "%s"' % d)
|
|
| 156 |
+ else: |
|
| 144 | 157 |
logging.debug("Select mailbox")
|
| 145 | 158 |
ret = server.select(options.mailbox) |
| 146 | 159 |
if len(ret)>0 and ret[0]=='OK': |
| 147 | 160 |
logging.info("Mailbox %s content %s message(s)" % (options.mailbox,ret[1][0]))
|
| 148 | 161 |
else: |
| 149 | 162 |
logging.error("Selecting return incorrected : %s" % ret)
|
| 163 |
+ server.close() |
|
| 150 | 164 |
except Exception as e: |
| 151 | 165 |
logging.critical('Error selecting mailbox %s : %s' % (option.mailbox,e))
|
| 152 | 166 |
finally: |
| 153 |
- server.close() |
|
| 154 | 167 |
server.logout() |
| 155 | 168 |