From 533628c2fced445063d68fd05578ed05ce7ac05e Mon Sep 17 00:00:00 2001 From: Nikolaus Schulz Date: Thu, 14 Feb 2008 22:19:34 +0000 Subject: Only try CRAM-MD5 authentication if the server advertises it. --- archivemail.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/archivemail.py b/archivemail.py index 98644bf..37edbb7 100755 --- a/archivemail.py +++ b/archivemail.py @@ -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 -- cgit v1.2.3