Hi all.  New to running a mailserver, and I want to make sure I really
understand what's happening with it, strange behaviors, and try to
prevent misconfigurations.

What I'd like to do is slowly filter out specific notifications I
don't care about.  The example I'll use right now is 'Relay Access
Denied'.  I'd like to process and filter these messages on the server
(not MUA) so I can (for example) send them to a statsd instance and
look for variances in their frequency.  (Maybe to alert me how one day
I mess up and enable open relaying.)  I liked the idea of filtering
these error messages with a milter, since it lets me plug into the
lifecycle of a message while running arbitrary code.

Right now I have postfix set up with verbose logging with and the milter as:

notify_classes = bounce, 2bounce, delay, policy, protocol, resource, software
non_smtpd_milters = unix:/var/spool/errorloggingmilter
smtpd_milters = unix:/var/spool/errorloggingmilter

The milter itself does something simple, relevant code:
    @Milter.noreply
    def connect(self, IPname, family, hostaddr):
        self.msg = ""
        return Milter.CONTINUE

    @Milter.noreply
    def body(self, chunk):
        self.msg += chunk
        return Milter.CONTINUE

    def eom(self):
        print "Hit EOM!"
        print self.msg
        sys.stdout.flush()
        if isSpecificError(self.msg.strip()):
            print "Specific Error"
            return Milter.DISCARD
        else:
            return Milter.CONTINUE

I got it configured and plugged in, but it wasn't filtering the Relay
Access emails.  Running smtpd -v showed me the following:
http://pastebin.com/ka3wTsjx which I interpret as taking the Relay
Access error and dumping it directly into the maildir without sending
it through my milter.

It seems like my assumptions about how milters work is incorrect.
What's the best way to try and accomplish what I'm after?

-tom

Reply via email to