pymilter
0.9.6
|
A thin wrapper around libmilter. More...
Classes | |
class | milterContext |
Hold context for a milter connection. More... | |
class | error |
Functions | |
def | set_flags |
Enable optional milter actions. More... | |
def | set_connect_callback |
def | set_helo_callback |
def | set_envfrom_callback |
def | set_envrcpt_callback |
def | set_header_callback |
def | set_eoh_callback |
def | set_body_callback |
def | set_abort_callback |
def | set_close_callback |
def | set_exception_policy |
Sets the return code for untrapped Python exceptions during a callback. More... | |
def | register |
Register python milter with libmilter. More... | |
def | opensocket |
def | main |
Transfer control to libmilter. More... | |
def | setdbg |
Set the libmilter debugging level. More... | |
def | settimeout |
Set timeout for MTA communication. More... | |
def | setbacklog |
Set socket backlog. More... | |
def | setconn |
Set the socket used to communicate with the MTA. More... | |
def | stop |
Stop the milter gracefully. More... | |
def | getdiag |
Retrieve diagnostic info. More... | |
def | getversion |
Retrieve the runtime libmilter version. More... | |
Variables | |
int | VERSION = 0x1000001 |
The compile time libmilter version. More... | |
A thin wrapper around libmilter.
def milter.getdiag | ( | ) |
Retrieve diagnostic info.
Return a tuple with diagnostic info gathered by the milter module. The first two fields are counts of milterContext objects created and deleted. Additional fields may be added later.
def milter.getversion | ( | ) |
Retrieve the runtime libmilter version.
Return the runtime libmilter version. This can be different from the compile time version when sendmail or libmilter is upgraded after pymilter is compiled.
(major,minor,patchlevel)
Referenced by Milter.runmilter().
def milter.main | ( | ) |
def milter.register | ( | name, | |
negotiate = None , |
|||
unknown = None , |
|||
data = None |
|||
) |
Register python milter with libmilter.
The name we pass is used to identify the milter in the MTA configuration. Callback functions must be set using the set_*_callback() functions before registering the milter. Three additional callbacks are specified as keyword parameters. These were added by recent versions of libmilter. The keyword parameters is a nicer way to do it, I think, since it makes clear that you have to do it before registering. I may move all the callbacks in the future (perhaps keeping the set functions for compatibility).
name | the milter name by which the MTA finds us |
negotiate | the xxfi_negotiate callback, called to negotiate supported actions, callbacks, and protocol steps. |
unknown | the xxfi_unknown callback, called when for SMTP commands not recognized by the MTA. (Extend SMTP in your milter!) |
data | the xxfi_data callback, called when the DATA SMTP command is received. |
Referenced by Milter.runmilter().
def milter.set_exception_policy | ( | code | ) |
Sets the return code for untrapped Python exceptions during a callback.
Must be one of TEMPFAIL,REJECT,CONTINUE. The default is TEMPFAIL. You should not depend on this handler. Your application should have its own top level exception handler for each callback. You can then choose your own reply message, log the stack track were you please, and so on. However, if you miss one, this last ditch handler will print a standard stack trace to sys.stderr, and return to sendmail.
def milter.set_flags | ( | flags | ) |
Enable optional milter actions.
Certain milter actions need to be enabled before calling main() or they throw an exception. Pymilter enables them all by default (since 0.9.2), but you may wish to disable unneeded actions as an optimization.
flags | Bit or mask of optional actions to enable |
def milter.setbacklog | ( | n | ) |
Set socket backlog.
Calls smfi_setbacklog. Must be called before calling main().
def milter.setconn | ( | s | ) |
Set the socket used to communicate with the MTA.
The MTA can communicate with the milter by means of a unix, inet, or inet6 socket. By default, a unix domain socket is used. It must not exist, and sendmail will throw warnings if, eg, the file is under a group or world writable directory.
setconn('unix:/var/run/pythonfilter') setconn('inet:8800') # listen on ANY interface setconn('inet:7871@publichost') # listen on a specific interface setconn('inet6:8020')
Referenced by Milter.runmilter().
def milter.setdbg | ( | lev | ) |
Set the libmilter debugging level.
smfi_setdbg sets the milter library's internal debugging level to a new level so that code details may be traced. A level of zero turns off debugging. The greater (more positive) the level the more detailed the debugging. Six is the current, highest, useful value. Must be called before calling main().
def milter.settimeout | ( | secs | ) |
Set timeout for MTA communication.
Calls smfi_settimeout. Must be called before calling main().
Referenced by Milter.runmilter().
def milter.stop | ( | ) |
Stop the milter gracefully.
int milter.VERSION = 0x1000001 |
The compile time libmilter version.
Python code might need to deal with pymilter compiled against various versions of libmilter. This module constant contains the contents of the SMFI_VERSION
macro when the milter module was compiled.