From stuart at bmsi.com Fri Jan 18 13:21:14 2008 From: stuart at bmsi.com (Stuart D. Gathman) Date: Fri, 18 Jan 2008 13:21:14 -0500 (EST) Subject: [Pymilter] Re: simple email list in python In-Reply-To: <478B2028.3000305@gmail.com> Message-ID: On Mon, 14 Jan 2008, Mark wrote: > so can i start reading the emails to python from that mta > > How to set this up to read messages from the mta In pymilter, you collect the email in header and body. For instance: def envfrom(self,f,*str): self.log("mail from",f,str) self.fp = StringIO.StringIO() # or use temp file self.bodysize = 0 ... def header(self,name,val): ... self.fp.write("%s: %s\n" % (name,val)) # add header to buffer return Milter.CONTINUE def eoh(self): self.fp.write("\n") # blank line after header ... return Milter.CONTINUE def body(self,chunk): # copy body to temp file self.fp.write(chunk) # IOError causes TEMPFAIL in milter self.bodysize += len(chunk) return Milter.CONTINUE def eom(self): self.fp.seek(0) msg = mime.message_from_file(self.fp) ... -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flammis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial.