def email_receiver(cmd,msg): T = Tester() T.newtest(testname=cmd) # Save the received email mesasge in the database messageid = T.insert_email_message(tester.EMAIL_TAG_USER_SENT,str(msg)) args = {"messageid":messageid,"cmd":cmd} # Depending on the command, institute the next step... if cmd=="bouncer": T.insert_task(tester.TASK_COMPOSE_SIMPLE_RESPONSE, args) T.commit() elif cmd=="register": T.insert_task(tester.TASK_REGISTER_FROM_EMAIL, args) T.commit() else: # Log invalid command logging.info("Invalid command: {} Message {}".format(cmd,messageid))
dbname = cfg.get("mysql","dbname") cmd = ['mysqldump','-u'+username,'-p'+password,'-d',dbname] sys.stdout.write(Popen(cmd,stdout=PIPE).communicate()[0].decode('utf-8')) if args.message: c.execute("select body,smtp_log from messages where messageid=%s",(args.message,)) (body,log) = c.fetchone() print("Message Body:") print(body) if log: print("") print("SMTP Log") print(log) if args.dumpsmtp: c.execute("select smtp_log from messages where messageid=%s",(args.dumpsmtp,)) print(c.fetchone()[0]) if args.resend: import periodic c.execute("insert into messages (testid,body,received,toaddr,fromaddr,tag) select testid,body,received,toaddr,fromaddr,tag from messages where messageid=%s;",(args.resend)) messageid = c.lastrowid c.execute("select testid from messages where messageid=%s",(messageid,)) testid = c.fetchone()[0] print("testid=",testid) T.testid = testid T.insert_task(tester.TASK_SEND_MESSAGE, {"messageid": c.lastrowid}) print("running periodic...") periodic.periodic()