aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolaus Schulz <microschulz@web.de>2008-02-14 22:24:16 +0000
committerNikolaus Schulz <microschulz@web.de>2008-02-14 22:24:16 +0000
commit6abf732d2e1a6f104970767358081d095535674a (patch)
treeb16e4407e826535f655385fcfc4bf9a9605c015a
parent533628c2fced445063d68fd05578ed05ce7ac05e (diff)
downloadarchivemail-6abf732d2e1a6f104970767358081d095535674a.tar.gz
archivemail-6abf732d2e1a6f104970767358081d095535674a.tar.bz2
archivemail-6abf732d2e1a6f104970767358081d095535674a.zip
IMAP: catch LOGINDISABLED, and suggest using imaps.
-rwxr-xr-xarchivemail.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/archivemail.py b/archivemail.py
index 37edbb7..8f6fb9c 100755
--- a/archivemail.py
+++ b/archivemail.py
@@ -1347,7 +1347,8 @@ def _archive_imap(mailbox_name, final_archive_name):
unexpected_error("No imap password specified")
imap_password = getpass.getpass('IMAP password: ')
- if mailbox_name[:5].lower() == 'imaps':
+ is_ssl = mailbox_name[:5].lower() == 'imaps'
+ if is_ssl:
vprint("establishing secure connection to server %s" % imap_server)
imap_srv = imaplib.IMAP4_SSL(imap_server)
else:
@@ -1357,9 +1358,15 @@ def _archive_imap(mailbox_name, final_archive_name):
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)
- else:
+ elif not "LOGINDISABLED" in imap_srv.capabilities:
vprint("logging in to server as %s" % imap_username)
result, response = imap_srv.login(imap_username, imap_password)
+ else:
+ if not is_ssl:
+ user_error("imap server %s has login disabled (hint: "
+ "try ssl/imaps)" % imap_server)
+ else: # Shouldn't happen
+ unexpected_error("imap server %s has login disabled!" % imap_server)
roflag = options.dry_run or options.copy_old_mail
# Work around python bug #1277098 (still pending in python << 2.5)