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

durwin at mgtsciences.com durwin at mgtsciences.com
Thu Oct 20 11:33:06 EDT 2011


Durwin F. De La Rue
Management Sciences, Inc.
6022 Constitution Ave. NE
Albuquerque, NM  87110
Phone (505) 255-8611

"Stuart D. Gathman" <stuart at bmsi.com> wrote on 10/19/2011 05:05:15 PM:

> "Stuart D. Gathman" <stuart at bmsi.com> 
> 10/19/2011 05:05 PM
> 
> To
> 
> durwin at mgtsciences.com
> 
> cc
> 
> pymilter at bmsi.com
> 
> Subject
> 
> Re: [Pymilter] Where do I find details of the class variables?
> 
> 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 am beginning to understand what is occurring.  Does milter-template.py 
pass the email through unmodified?  As I see it, it copies the email into 
a string buffer (as it gets each piece) and in the end returns the string 
buffer as the email?  It never modifies the email directly? It does look 
like the from is being modified in 'envfrom'.

When 'header' is called with each header field, I would just look for 
'Received:' in 'name' and parse the 'hval' string for what I want?

Since the string buffer is created in envfrom, is it the first callback 
(after the init and connect)?

What is 'envfrom' and 'envrcpt'?  Aren't the from and recipient fields 
sent to header are well?
Where is 'log' writing to?  maillog?  Would 'log ' be a good place to put 
debug information?
What does background do?

> 
> > 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.


Thank you for your time.

Durwin


This email message and any attachments are for the sole use of the 
intended recipient(s) and may contain proprietary and/or confidential 
information which may be privileged or otherwise protected from 
disclosure. Any unauthorized review, use, disclosure or distribution is 
prohibited. If you are not the intended recipient(s), please contact the 
sender by reply email and destroy the original message and any copies of 
the message as well as any attachments to the original message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gathman.org/pipermail/pymilter/attachments/20111020/738e3b29/attachment.html>


More information about the Pymilter mailing list