+- transparent "&" escaping
- automatic changelog generation
- support for more IMAP functions: sort, examine etc
+ - someone sent a patch for this?
- write a comparision of imaplib vs imapclient.py
(presentation is a good start)
- abstract out UID handling if possible
- higher level fetch methods for common attributes, flattened
- handling read-only access
-- transparent "&" escaping
- more unit tests using mocking
-- SSL support
- allow per-call uid overrides
- more docs
- better namespace support
re_status = re.compile(r'^\s*"(?P<folder>[^"]+)"\s+'
r'\((?P<status_items>.*)\)$')
- def __init__(self, host, port=143, use_uid=True):
+ def __init__(self, host, port=None, use_uid=True, ssl=False):
'''Initialise object instance and connect to the remote IMAP server.
@param host: The IMAP server address/hostname to connect to.
- @param port: The port number to use (default is 143).
+ @param port: The port number to use (default is 143, 993 for SSL).
@param use_uid: Should message UIDs be used (default is True).
+ @param ssl: Make an SSL connection (default is False)
'''
- self._imap = imaplib.IMAP4(host, port)
+ if ssl:
+ ImapClass = imaplib.IMAP4_SSL
+ default_port = 993
+ else:
+ ImapClass = imaplib.IMAP4
+ default_port = 143
+
+ if port is None:
+ port = default_port
+
+ self._imap = ImapClass(host, port)
self.use_uid = use_uid
def login(self, username, password):
def command_line():
p = OptionParser()
p.add_option('-H', '--host', dest='host', action='store',
- help='IMAP host connect to')
+ help='IMAP host connect to')
p.add_option('-P', '--port', dest='port', action='store',
- default=143, help='IMAP port to use (default is 143)')
+ default=143, help='IMAP port to use (default is 143)')
+ p.add_option('-s', '--ssl', dest='ssl', action='store_true', default=False,
+ help='Use SSL connection')
p.add_option('-u', '--username', dest='username', action='store',
- help='Username to login with')
+ help='Username to login with')
p.add_option('-p', '--password', dest='password', action='store',
- help='Password to login with')
+ help='Password to login with')
p.add_option('', '--clobber', dest='clobber', action='store_true',
- default=False, help='These tests are destructive. Use this '
- 'option to bypass the confirmation prompt.')
+ default=False, help='These tests are destructive. Use this '
+ 'option to bypass the confirmation prompt.')
options, args = p.parse_args()
return options
+
def user_confirm():
print """\
WARNING: These tests are destructive.
# Test with use_uid on and off
for use_uid in (True, False):
print '-'*60
- print "Testing with use_uid=%r..." % use_uid
+ print "Testing with use_uid=%r, ssl=%r..." % (use_uid, options.ssl)
print '-'*60
- server = imapclient.IMAPClient(options.host, use_uid=use_uid)
+ server = imapclient.IMAPClient(options.host, use_uid=use_uid, ssl=options.ssl)
server.login(options.username, options.password)
runtests(server)
print 'SUCCESS'