comparison roundup/scripts/roundup_mailgw.py @ 4345:38265325492a

support CRAM-MD5 for IMAPS
author Richard Jones <richard@users.sourceforge.net>
date Tue, 02 Feb 2010 05:15:10 +0000
parents 61cf00ca920a
children 6e3e4f24c753
comparison
equal deleted inserted replaced
4344:85b00a3820b3 4345:38265325492a
103 IMAPS: 103 IMAPS:
104 Connect to an IMAP server over ssl. 104 Connect to an IMAP server over ssl.
105 This supports the same notation as IMAP. 105 This supports the same notation as IMAP.
106 imaps username:password@server [mailbox] 106 imaps username:password@server [mailbox]
107 107
108 IMAPS_CRAM:
109 Connect to an IMAP server over ssl using CRAM-MD5 authentication.
110 This supports the same notation as IMAP.
111 imaps_cram username:password@server [mailbox]
112
108 """)%{'program': args[0]} 113 """)%{'program': args[0]}
109 return 1 114 return 1
110 115
111 def main(argv): 116 def main(argv):
112 '''Handle the arguments to the program and initialise environment. 117 '''Handle the arguments to the program and initialise environment.
151 if len(args) < 3: 156 if len(args) < 3:
152 return usage(argv, _('Error: not enough source specification information')) 157 return usage(argv, _('Error: not enough source specification information'))
153 source, specification = args[1:3] 158 source, specification = args[1:3]
154 159
155 # time out net connections after a minute if we can 160 # time out net connections after a minute if we can
156 if source not in ('mailbox', 'imaps'): 161 if source not in ('mailbox', 'imaps', 'imaps_cram'):
157 if hasattr(socket, 'setdefaulttimeout'): 162 if hasattr(socket, 'setdefaulttimeout'):
158 socket.setdefaulttimeout(60) 163 socket.setdefaulttimeout(60)
159 164
160 if source == 'mailbox': 165 if source == 'mailbox':
161 return handler.do_mailbox(specification) 166 return handler.do_mailbox(specification)
187 return usage(argv, _('Error: a later version of python is required')) 192 return usage(argv, _('Error: a later version of python is required'))
188 return handler.do_pop(server, username, password, ssl) 193 return handler.do_pop(server, username, password, ssl)
189 elif source == 'apop': 194 elif source == 'apop':
190 return handler.do_apop(server, username, password) 195 return handler.do_apop(server, username, password)
191 elif source.startswith('imap'): 196 elif source.startswith('imap'):
192 ssl = source.endswith('s') 197 ssl = cram = 0
198 if source.endswith('s'):
199 ssl = 1
200 elif source.endswith('s_cram'):
201 ssl = cram = 1
193 mailbox = '' 202 mailbox = ''
194 if len(args) > 3: 203 if len(args) > 3:
195 mailbox = args[3] 204 mailbox = args[3]
196 return handler.do_imap(server, username, password, mailbox, ssl) 205 return handler.do_imap(server, username, password, mailbox, ssl,
206 cram)
197 207
198 return usage(argv, _('Error: The source must be either "mailbox",' 208 return usage(argv, _('Error: The source must be either "mailbox",'
199 ' "pop", "pops", "apop", "imap" or "imaps"')) 209 ' "pop", "pops", "apop", "imap", "imaps" or "imaps_cram'))
200 210
201 def run(): 211 def run():
202 sys.exit(main(sys.argv)) 212 sys.exit(main(sys.argv))
203 213
204 # call main 214 # call main

Roundup Issue Tracker: http://roundup-tracker.org/