[Pymilter] Unknown command and further processing
Stuart D Gathman
stuart at bmsi.com
Wed May 23 15:45:23 EDT 2012
On 05/23/2012 03:23 PM, Larry G. Wapnitsky expounded in part:
>
> Also, I understand how to set the flag, but how do I control the
> header, etc. reading? What's the order that the commands are usually
> processed in, and should I remove Milter.noreply from header reading,
> etc.?
>
There is no point in removing Miler.noreply unless you ever return
something other than Milter.CONTINUE.
SMTP protocol defines the order of commands (and therefore callbacks).
Any deviation causes the client to be rejected. Here is a summary:
connect
helo
---- repeat for each message -----
envfrom
envrcpt
... envrcpt --- repeat for each rcpt
data
header
... header --- repeat for each header
eoh
body
... body --- repeat for each body chunk
eom
-------------------------------------------
close
For instance, (untested, from the top of my head):
@Milter.noreply
def envfrom(self,from,args):
self.unknown_seen = False
self.fp = None
...
return Milter.CONTINUE
@Milter.noreply
def unknown(self,cmd):
self.log('Unknown:',cmd)
self.unknown_seen = True
self.fp = StringIO.StringIO()
return Milter.CONTINUE
@Milter.noreply
def header(self,name,val):
if self.unknown_seen:
self.fp.write("%s: %s\n" % (name,val))
return Milter.CONTINUE
@Milter.noreply
def eoh(self):
if self.unknown_seen:
self.fp.write('\n')
return Milter.CONTINUE
@Milter.noreply
def body(self,buf):
if self.unknown_seen:
self.fp.write(buf)
return Milter.CONTINUE
@Milter.noreply
def eom(self):
if self.unknown_seen:
self.fp.seek(0)
self.store_in_database(self.fp.getvalue())
return Milter.CONTINUE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gathman.org/pipermail/pymilter/attachments/20120523/dde5210c/attachment-0001.html>
More information about the Pymilter
mailing list