mirror of
https://git.code.sf.net/p/archivemail/code
synced 2024-12-22 07:42:55 +00:00
IMAP: support servers listening on non-standard ports
This commit is contained in:
parent
f9f9eacd88
commit
eb07611fae
2 changed files with 21 additions and 8 deletions
|
@ -7,6 +7,7 @@ version 0.?.? - UNRELEASED
|
||||||
FixedGzipFile.seek() return the new absolute file position.
|
FixedGzipFile.seek() return the new absolute file position.
|
||||||
Closes: #3314293.
|
Closes: #3314293.
|
||||||
* IMAP: support international mailbox names containing non-ASCII characters.
|
* IMAP: support international mailbox names containing non-ASCII characters.
|
||||||
|
* IMAP: support servers listening on non-standard ports. Closes: #3168416.
|
||||||
|
|
||||||
version 0.8.2 - 16 October 2010
|
version 0.8.2 - 16 October 2010
|
||||||
|
|
||||||
|
|
28
archivemail
28
archivemail
|
@ -1290,9 +1290,9 @@ def _archive_imap(mailbox_name):
|
||||||
vprint("Setting imaplib.Debug = %d" % options.debug_imap)
|
vprint("Setting imaplib.Debug = %d" % options.debug_imap)
|
||||||
imaplib.Debug = options.debug_imap
|
imaplib.Debug = options.debug_imap
|
||||||
archive = None
|
archive = None
|
||||||
imap_str = mailbox_name[mailbox_name.find('://') + 3:]
|
imap_username, imap_password, \
|
||||||
imap_username, imap_password, imap_server, imap_folder_pattern = \
|
imap_server, imap_server_port, \
|
||||||
parse_imap_url(imap_str)
|
imap_folder_pattern = parse_imap_url(mailbox_name)
|
||||||
if not imap_password:
|
if not imap_password:
|
||||||
if options.pwfile:
|
if options.pwfile:
|
||||||
imap_password = open(options.pwfile).read().rstrip()
|
imap_password = open(options.pwfile).read().rstrip()
|
||||||
|
@ -1303,11 +1303,13 @@ def _archive_imap(mailbox_name):
|
||||||
|
|
||||||
is_ssl = mailbox_name[:5].lower() == 'imaps'
|
is_ssl = mailbox_name[:5].lower() == 'imaps'
|
||||||
if is_ssl:
|
if is_ssl:
|
||||||
vprint("establishing secure connection to server %s" % imap_server)
|
vprint("establishing secure connection to server %s, port %s" %
|
||||||
imap_srv = imaplib.IMAP4_SSL(imap_server)
|
(imap_server, imap_server_port))
|
||||||
|
imap_srv = imaplib.IMAP4_SSL(imap_server, imap_server_port)
|
||||||
else:
|
else:
|
||||||
vprint("establishing connection to server %s" % imap_server)
|
vprint("establishing connection to server %s, port %s" %
|
||||||
imap_srv = imaplib.IMAP4(imap_server)
|
(imap_server, imap_server_port))
|
||||||
|
imap_srv = imaplib.IMAP4(imap_server, imap_server_port)
|
||||||
if "AUTH=CRAM-MD5" in imap_srv.capabilities:
|
if "AUTH=CRAM-MD5" in imap_srv.capabilities:
|
||||||
vprint("authenticating (cram-md5) to server as %s" % imap_username)
|
vprint("authenticating (cram-md5) to server as %s" % imap_username)
|
||||||
result, response = imap_srv.login_cram_md5(imap_username, imap_password)
|
result, response = imap_srv.login_cram_md5(imap_username, imap_password)
|
||||||
|
@ -1551,6 +1553,7 @@ def parse_imap_url(url):
|
||||||
a, b = string.split(delim, 1)
|
a, b = string.split(delim, 1)
|
||||||
return a, b
|
return a, b
|
||||||
|
|
||||||
|
scheme, url = url.split('://')
|
||||||
password = None
|
password = None
|
||||||
try:
|
try:
|
||||||
if options.pwfile:
|
if options.pwfile:
|
||||||
|
@ -1566,7 +1569,16 @@ def parse_imap_url(url):
|
||||||
server, folder = url.split('/', 1)
|
server, folder = url.split('/', 1)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
unexpected_error("Invalid IMAP connection string")
|
unexpected_error("Invalid IMAP connection string")
|
||||||
return username, password, server, folder
|
try:
|
||||||
|
server, port = server.split(':')
|
||||||
|
except ValueError:
|
||||||
|
if scheme.lower() == 'imap':
|
||||||
|
port = 143
|
||||||
|
else:
|
||||||
|
port = 993
|
||||||
|
else:
|
||||||
|
port = int(port)
|
||||||
|
return username, password, server, port, folder
|
||||||
|
|
||||||
|
|
||||||
def imap_getdelim(imap_server):
|
def imap_getdelim(imap_server):
|
||||||
|
|
Loading…
Reference in a new issue