mirror of
https://git.code.sf.net/p/archivemail/code
synced 2024-12-23 16:25:36 +00:00
- fix last patch: don't fail if server URL doesn't contain username of password; try plain as well as cram-md5 login
This commit is contained in:
parent
a91b2064cb
commit
07aca153f6
1 changed files with 4 additions and 6 deletions
|
@ -1226,12 +1226,11 @@ def _archive_imap(mailbox_name, final_archive_name):
|
||||||
filter = build_imap_filter()
|
filter = build_imap_filter()
|
||||||
vprint("imap filter: '%s'" % filter)
|
vprint("imap filter: '%s'" % filter)
|
||||||
try:
|
try:
|
||||||
|
imap_server, imap_folder = imap_str.split('/', 1)
|
||||||
imap_username, imap_str = imap_str.split(':', 1)
|
imap_username, imap_str = imap_str.split(':', 1)
|
||||||
imap_password, imap_str = imap_str.split('@', 1)
|
imap_password, imap_str = imap_str.split('@', 1)
|
||||||
imap_server, imap_folder = imap_str.split('/', 1)
|
|
||||||
except:
|
except:
|
||||||
unexpected_error("you must provide a properly formatted \
|
pass
|
||||||
IMAP connection string")
|
|
||||||
imap_username = getpass.getuser()
|
imap_username = getpass.getuser()
|
||||||
if options.pwfile:
|
if options.pwfile:
|
||||||
imap_password = open(options.pwfile).read().rstrip()
|
imap_password = open(options.pwfile).read().rstrip()
|
||||||
|
@ -1245,10 +1244,9 @@ def _archive_imap(mailbox_name, final_archive_name):
|
||||||
else:
|
else:
|
||||||
imap_srv = imaplib.IMAP4(imap_server)
|
imap_srv = imaplib.IMAP4(imap_server)
|
||||||
vprint("connected to server %s" % imap_server)
|
vprint("connected to server %s" % imap_server)
|
||||||
cram_md5 = True
|
try:
|
||||||
if cram_md5:
|
|
||||||
result, response = imap_srv.login_cram_md5(imap_username, imap_password)
|
result, response = imap_srv.login_cram_md5(imap_username, imap_password)
|
||||||
else:
|
except:
|
||||||
result, response = imap_srv.login(imap_username, imap_password)
|
result, response = imap_srv.login(imap_username, imap_password)
|
||||||
if result != 'OK': unexpected_error("authentication failure")
|
if result != 'OK': unexpected_error("authentication failure")
|
||||||
vprint("logged in to server as %s" % imap_username)
|
vprint("logged in to server as %s" % imap_username)
|
||||||
|
|
Loading…
Reference in a new issue