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

Stuart D. Gathman stuart at bmsi.com
Thu Oct 20 14:38:46 EDT 2011


On Thu, 20 Oct 2011, durwin at mgtsciences.com wrote:

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

It parses the string buffer into an email.message object - but then
throws it away.  It is just an example of how to collect the email message,
since that it a FAQ.

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

Yes. Name would just be "Received".

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

It is the first callback for each message.  There can be multiple messages
on a connection.

> What is 'envfrom' and 'envrcpt'?  Aren't the from and recipient fields sent
> to header are well?

NO NO NO!  The envfrom is supposed to be copied to the Return-Path header
field but your MTA, but otherwise there is no relation.  The envrcpt is what is
actually used to deliver the email, NOT the "To" header field (which is
basically just commentary and can be any garbage).  The envfrom is where any
DSNs are sent.  The envfrom can be efficiently validated using the SPF protocol
(you can use pyspf to implement), and if validated is the actual source of the
email (as opposed to header From which can be any garbage).  Think of header
fields as letter head, and envfrom/envrcpt as the actually address and return
address on the envelope.

> Where is 'log' writing to?  maillog?  Would 'log ' be a good place to put
> debug information?

Milter.Base.log does nothing.  Milter.Milter.log sends log to stdout.
milter-template.myMilter.log sends log to a background process, which
then prints it to stdout (to illustrate how to use multiprocessing with
pymilter).  In the milter package, bms.py and spfmilter.py send the log
to the logging module, which is configured by default for 
stdout and syslog.mail respectively.

> What does background do?

Threads can't usually harness multiple CPUs in python due to the GIL.
Also, user defined signal handling is problematic when using libmilter (as
pymilter does).  So the multiprocessing module is the easy way to do parallel
processing in pure python, and works well with pymilter.

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