[Pymilter] Where do I find details of the class variables?

Stuart D. Gathman stuart at bmsi.com
Wed Oct 19 19:05:15 EDT 2011


On Wed, 19 Oct 2011, durwin at mgtsciences.com wrote:

> I have the milter-template working.  I want to access the 'Received:'
> headers and search them for the IP address of the server it came from.

Short answer: You don't need to do that.

Long answer: If you did need to search the Received headers, the header call
back is called for each header field and provides the field name and
value for each header in turn (as it is received by sendmail/postfix).

However, your milter is called in real time as the message is received,
and the connect ip is provided in the connect callback - so there is usually
no need to search received headers.  I generally save this to self.connectip.
(milter-template.py saves it to self.IP).

Advanced answer: If you are running "behind" another (trusted) MX, and you want
the ip that connected to *that* MX, then the first Received header encountered
by the header callback has the information.  You could generalize this,
and make self.connectip a list, which gets the the current connect ip as the
first member, and appends addition ips from received headers in order.
So *if* self.connectip[0] is trusted, then the IP that connected to it
is self.connectip[1].  (I would post sample code, but don't know how to
parse the Received header right off the bat.)

> I see a whole lot of lines with 'self.<something>' but I can't find
> where to get details about each of those. What variables are available to
> me?

Short answer: None

Long answer: In python, you create instance variables by just assigning them.
There are no public instance variables in Milter.Base except ones you create.
There are public methods, and callbacks.  The callbacks provide
information in the arguments (for example the helo callback provides
the helo name used), and additional information can gotten from
methods like getsymval().

Vaporware answer: I have thought about providing a plugin framework
on top of Milter.Base, which would include standard information gathering
plugins.  This is not much of a win for a single purpose milter (such
as you are probably writing), but would help organize bloated, overgrown,
all singing, all dancing multi-purpose milters such as bms.py milter
(in the milter package).

> Can anyone direct me to the documentation I need?

http://spidey2.bmsi.com/pymilter/

(on the left side navbar on pymilter page)

--
 	      Stuart D. Gathman <stuart at bmsi.com>
     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.



More information about the Pymilter mailing list