comparison roundup/scripts/roundup_mailgw.py @ 2210:b61640273061

added IMAP support to mail gateway (rfe [SF#934000])
author Richard Jones <richard@users.sourceforge.net>
date Tue, 13 Apr 2004 04:11:49 +0000
parents 3f89c8ffe4f1
children 272b654b1227
comparison
equal deleted inserted replaced
2209:0b76c4961802 2210:b61640273061
12 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 12 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 13 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
14 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 14 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
15 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 15 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
16 # 16 #
17 # $Id: roundup_mailgw.py,v 1.12 2004-04-05 23:43:03 richard Exp $ 17 # $Id: roundup_mailgw.py,v 1.13 2004-04-13 04:11:06 richard Exp $
18 18
19 """Command-line script stub that calls the roundup.mailgw. 19 """Command-line script stub that calls the roundup.mailgw.
20 """ 20 """
21 __docformat__ = 'restructuredtext' 21 __docformat__ = 'restructuredtext'
22 22
78 78
79 APOP: 79 APOP:
80 Same as POP, but using Authenticated POP: 80 Same as POP, but using Authenticated POP:
81 apop username:password@server 81 apop username:password@server
82 82
83 IMAP:
84 Connect to an IMAP server. This supports the same notation as that of POP mail.
85 imap username:password@server
86 It also allows you to specify a specific mailbox other than INBOX using this format:
87 imap username:password@server mailbox
88
89 IMAPS:
90 Connect to an IMAP server over ssl.
91 This supports the same notation as IMAP.
92 imaps username:password@server [mailbox]
93
83 ''') 94 ''')
84 return 1 95 return 1
85 96
86 def main(argv): 97 def main(argv):
87 '''Handle the arguments to the program and initialise environment. 98 '''Handle the arguments to the program and initialise environment.
124 return handler.do_pipe() 135 return handler.do_pipe()
125 136
126 # otherwise, figure what sort of mail source to handle 137 # otherwise, figure what sort of mail source to handle
127 if len(args) < 3: 138 if len(args) < 3:
128 return usage(argv, _('Error: not enough source specification information')) 139 return usage(argv, _('Error: not enough source specification information'))
129 source, specification = args[1:] 140 source, specification = args[1:3]
130 if source == 'mailbox': 141 if source == 'mailbox':
131 return handler.do_mailbox(specification) 142 return handler.do_mailbox(specification)
132 elif source == 'pop': 143 elif source == 'pop':
133 m = re.match(r'((?P<user>[^:]+)(:(?P<pass>.+))?@)?(?P<server>.+)', 144 m = re.match(r'((?P<user>[^:]+)(:(?P<pass>.+))?@)?(?P<server>.+)',
134 specification) 145 specification)
141 specification) 152 specification)
142 if m: 153 if m:
143 return handler.do_apop(m.group('server'), m.group('user'), 154 return handler.do_apop(m.group('server'), m.group('user'),
144 m.group('pass')) 155 m.group('pass'))
145 return usage(argv, _('Error: apop specification not valid')) 156 return usage(argv, _('Error: apop specification not valid'))
157 elif source == 'imap' or source == 'imaps':
158 m = re.match(r'((?P<user>[^:]+)(:(?P<pass>.+))?@)?(?P<server>.+)',
159 specification)
160 if m:
161 ssl = False
162 if source == 'imaps':
163 ssl = True
164 mailbox = ''
165 if len(args) > 3:
166 mailbox = args[3]
167 return handler.do_imap(m.group('server'), m.group('user'),
168 m.group('pass'), mailbox, ssl)
146 169
147 return usage(argv, _('Error: The source must be either "mailbox", "pop" or "apop"')) 170 return usage(argv, _('Error: The source must be either "mailbox", "pop" or "apop"'))
148 finally: 171 finally:
149 db.close() 172 db.close()
150 173

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