Changeset 43
- Timestamp:
- 01/26/06 13:48:25 (17 years ago)
- Location:
- emailtotracscript/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
emailtotracscript/trunk/email2trac.conf
r42 r43 5 5 spam_level: 4 6 6 reply_address: 1 7 reply_all : 1 7 8 mailto_link: 1 8 9 umask: 022 -
emailtotracscript/trunk/email2trac.py.in
r42 r43 140 140 else: 141 141 self.notify_template = None 142 143 if parameters.has_key('reply_all'): 144 self.REPLY_ALL = int(parameters['reply_all']) 145 else: 146 self.REPLY_ALL = 0 142 147 143 148 … … 232 237 return str 233 238 239 def set_owner(self, ticket): 240 cursor = self.db.cursor() 241 sql = "SELECT owner FROM component WHERE name='%s'" % ticket['component'] 242 cursor.execute(sql) 243 ticket['owner'] = cursor.fetchone()[0] 244 245 246 def set_reply_fields(self, ticket, message): 247 author, email_addr = email.Utils.parseaddr(message['from']) 248 email_str = self.to_unicode(message['from']) 249 250 ticket['reporter'] = email_str 251 ticket['cc'] = None 252 253 # Put all addresses in ticket CC field 254 # 255 if self.REPLY_ALL: 256 tos = message.get_all('to', []) 257 ccs = message.get_all('cc', []) 258 259 addrs = email.Utils.getaddresses(tos + ccs) 260 261 # Remove reporter email address if notification is 262 # on 263 # 264 if self.notification: 265 try: 266 addrs.remove((author, email_addr)) 267 except ValueError, detail: 268 pass 269 270 for a,m in addrs: 271 if not ticket['cc']: 272 ticket['cc'] = m 273 else: 274 ticket['cc'] = '%s,%s' %(ticket['cc'], m) 275 276 # Put authors email addess in CC field only if notification is off 277 # 278 elif self.CC and not self.notification: 279 ticket['cc'] = email_str 280 281 return author, email_addr 282 234 283 def parse(self, fp): 235 284 msg = email.message_from_file(fp) … … 252 301 tkt['status'] = 'new' 253 302 303 if self.get_config('notification', 'smtp_enabled') in ['true']: 304 self.notification = 1 305 254 306 # Some defaults 255 307 # … … 277 329 # sys.exit(1) 278 330 279 # Get default owner for component 280 # 281 cursor = self.db.cursor() 282 sql = "SELECT owner FROM component WHERE name='%s'" % tkt['component'] 283 cursor.execute(sql) 284 tkt['owner'] = cursor.fetchone()[0] 285 286 author, email_addr = email.Utils.parseaddr(msg['from']) 287 email_str = self.to_unicode(msg['from']) 288 if author: 289 tkt['reporter'] = email_str 290 else: 291 tkt['reporter'] = email_str 292 293 if self.CC: 294 tkt['cc'] = email_str 331 # Set default owner for component 332 # 333 self.set_owner(tkt) 334 author, email_addr = self.set_reply_fields(tkt, msg) 295 335 296 336 # produce e-mail like header … … 350 390 351 391 self.attachments(msg, tkt, author) 352 if self. get_config('notification', 'smtp_enabled') in ['true']:392 if self.notification: 353 393 self.notify(tkt) 354 394 -
emailtotracscript/trunk/test7.eml
r5 r43 16 16 X-Accept-Language: en-us, en 17 17 MIME-Version: 1.0 18 To: "Walter de Jong" <walter@sara.nl> 18 To: "Walter de Jong" <walter@sara.nl>, basv@sara.nl 19 19 Subject: test #7 20 20 Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg=sha1; boundary="------------ms030807040502080509050606"
Note: See TracChangeset
for help on using the changeset viewer.