#!/usr/bin/env python # This a notification system made for exo-helpdesk you will need notify-send (libnotify-bin in ubuntu) # Copyright (C) 2007 Gustavo Varela # USE AT YOUR OWN RISK # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. import imaplib import os import time server = "server.com" user = "user@server.com" passwd = "password" interval = 30 # In seconds. No more than 30 minutes. Check Autologout Timer in RFC print "Conecting..." M = imaplib.IMAP4(server) M.login(user, passwd) print "Connected!" while True: M.select() typ, data = M.search(None, 'NEW') print "Checking Mail...." for num in data[0].split(): (typ, data) = M.fetch(num, '(RFC822.TEXT)') if data[0][1].find("Ticket ID",0,100) == -1: title = "New Ticket" print title body = data[0][1][185:300] os.system("/usr/bin/notify-send \"%s\" \"%s\" " % (title,body)) else: title = 'New reply to Ticket ID:%s' % (data[0][1][65:71]) print title body = data[0][1][175:300] os.system("/usr/bin/notify-send \"%s\" \"%s\" " % (title,body)) time.sleep(interval) M.close() M.logout()