[Pymilter] Unknown command and further processing

Stuart D Gathman stuart at bmsi.com
Tue May 22 14:59:06 EDT 2012


Long ago, Nostradamus foresaw that on 05/22/2012 11:54 AM, Larry G. 
Wapnitsky would write:
>
> I have the following code in a milter that determines when Postfix has 
> received an unknown command:
>
> @Milter.noreply
>
>     def unknown(self, cmd):
>
>         self.unkMilterlog.warning('Invalid command sent: %s' % cmd)
>
>         try:
>
>             self.unkMilterlog.warning('From: %s' % self.canon_from)
>
>         except:
>
>             self.unkMilterlog.warning('unable to determine Sender')
>
>         try:
>
>             for R in self.R:
>
>                 for recipient in R:
>
>                     if not len(recipient) < 1: self.log('To %s' % 
> recipient)
>
>         except:
>
>             self.unkMilterlog.warning('unable to determine Recipient(s)')
>
>         return Milter.CONTINUE
>
> Is it possible to do further processing on a message when "unknown" 
> has been called?  Part of the reason this was initially created (for 
> logging purposes) was that another milter was not being hit when an 
> unknown command was being interpreted.  What I'd like to do is take 
> the full message and put it into a MySQL blob for further analysis.
>
Nothing about milter prevents further processing.   I tested with 
sendmail, results below.  What problem are you having, exactly?

Milter code:

   @Milter.noreply
   def unknown(self, cmd):
     self.log('Invalid command sent: %s' % cmd)
     return Milter.CONTINUE

Client side:

220 mail.bmsi.com ESMTP Sendmail 8.14.3/8.14.3; Tue, 22 May 2012 
14:50:40 -0400
HELO hulk
250 mail.bmsi.com Hello hulk [192.168.0.102], pleased to meet you
HELP
214-2.0.0 This is sendmail version 8.14.3
214-2.0.0 Topics:
214-2.0.0     HELO    EHLO    MAIL    RCPT    DATA
214-2.0.0     RSET    NOOP    QUIT    HELP    VRFY
214-2.0.0     EXPN    VERB    ETRN    DSN    AUTH
214-2.0.0     STARTTLS
214-2.0.0 For more info use "HELP <topic>".
214-2.0.0 To report bugs in the implementation see
214-2.0.0     http://www.sendmail.org/email-addresses.html
214-2.0.0 For local information send email to Postmaster at your site.
214 2.0.0 End of HELP info
PING super
500 5.5.1 Command unrecognized: "PING super"
MAIL FROM: <stuart at hulk.bmsi.com>
250 2.1.0 <stuart at hulk.bmsi.com>... Sender ok
RCPT TO: <stuart at bmsi.com>
250 2.1.5 <stuart at bmsi.com>... Recipient ok
SCRIBBLE: foo
500 5.5.1 Command unrecognized: "SCRIBBLE: foo"
DATA
354 Enter mail, end with "." on a line by itself
Testing
.
250 2.0.0 q4MIoefa002370 Message accepted for delivery
quit
221 2.0.0 mail.bmsi.com closing connection
Connection closed by foreign host.

Milter log:

2012May22 14:50:40 [1] connect from hulk at ('192.168.0.102', 34367) 
INTERNAL
2012May22 14:50:54 [1] hello from hulk
2012May22 14:51:14 [1] Invalid command sent: PING super
2012May22 14:51:49 [1] mail from <stuart at hulk.bmsi.com> ()
2012May22 14:51:58 [1] rcpt to <stuart at bmsi.com> ()
2012May22 14:52:06 [1] Invalid command sent: SCRIBBLE: foo
2012May22 14:52:17 [1] Authentication-Results: mail.bmsi.com; iprev=pass 
policy.iprev=192.168.0.102 (hulk)
2012May22 14:52:17 [1] X-DSpam-Score: 0.152536
2012May22 14:52:17 [1] eom


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gathman.org/pipermail/pymilter/attachments/20120522/f626d383/attachment.html>


More information about the Pymilter mailing list