Only try CRAM-MD5 authentication if the server advertises it.

This commit is contained in:
Nikolaus Schulz 2008-02-14 22:19:34 +00:00
parent 1fcd5b7292
commit 533628c2fc
1 changed files with 5 additions and 3 deletions

View File

@ -1353,10 +1353,12 @@ def _archive_imap(mailbox_name, final_archive_name):
else:
vprint("establishing connection to server %s" % imap_server)
imap_srv = imaplib.IMAP4(imap_server)
vprint("logging in to server as %s" % imap_username)
try:
# What about having an option that makes archivemail never try cram-md5?
if "AUTH=CRAM-MD5" in imap_srv.capabilities:
vprint("authenticating (cram-md5) to server as %s" % imap_username)
result, response = imap_srv.login_cram_md5(imap_username, imap_password)
except imaplib.IMAP4.error:
else:
vprint("logging in to server as %s" % imap_username)
result, response = imap_srv.login(imap_username, imap_password)
roflag = options.dry_run or options.copy_old_mail