\doxysection{Milter Namespace Reference}
\label{namespaceMilter}\index{Milter@{Milter}}
\doxysubsection*{Namespaces}
\begin{DoxyCompactItemize}
\item 
 \textbf{ dns}
\item 
 \textbf{ dsn}
\item 
 \textbf{ pyip6}
\item 
 \textbf{ sgmllib}
\item 
 \textbf{ test}
\item 
 \textbf{ testctx}
\item 
 \textbf{ utils}
\end{DoxyCompactItemize}
\doxysubsection*{Classes}
\begin{DoxyCompactItemize}
\item 
class \textbf{ Base}
\begin{DoxyCompactList}\small\item\em A do \char`\"{}nothing\char`\"{} \doxyref{Milter}{p.}{classMilter_1_1Milter} base class representing an S\+M\+TP connection. \end{DoxyCompactList}\item 
class \textbf{ Disabled\+Action}
\begin{DoxyCompactList}\small\item\em Disabled action exception. \end{DoxyCompactList}\item 
class \textbf{ Milter}
\begin{DoxyCompactList}\small\item\em A logging but otherwise do nothing \doxyref{Milter}{p.}{classMilter_1_1Milter} base class. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
def \textbf{ unique\+ID} ()
\item 
\mbox{\label{namespaceMilter_a8fbc342a2665f81340c6b77da04f0fba}} 
def {\bfseries decode\+\_\+mask} (bits, names)
\item 
def \textbf{ enable\+\_\+protocols} (klass, mask)
\begin{DoxyCompactList}\small\item\em Class decorator to enable optional protocol steps. \end{DoxyCompactList}\item 
def \textbf{ rejected\+\_\+recipients} (klass)
\begin{DoxyCompactList}\small\item\em \doxyref{Milter}{p.}{namespaceMilter} rejected recipients. \end{DoxyCompactList}\item 
def \textbf{ header\+\_\+leading\+\_\+space} (klass)
\begin{DoxyCompactList}\small\item\em \doxyref{Milter}{p.}{namespaceMilter} leading space on headers. \end{DoxyCompactList}\item 
def \textbf{ nocallback} (func)
\begin{DoxyCompactList}\small\item\em Function decorator to disable callback methods. \end{DoxyCompactList}\item 
def \textbf{ noreply} (func)
\begin{DoxyCompactList}\small\item\em Function decorator to disable callback reply. \end{DoxyCompactList}\item 
def \textbf{ symlist} ($\ast$syms)
\begin{DoxyCompactList}\small\item\em Function decorator to set macros used in a callback. \end{DoxyCompactList}\item 
\mbox{\label{namespaceMilter_ad3598adf6489982e50979239ef7df4e9}} 
def \textbf{ negotiate\+\_\+callback} (ctx, opts)
\begin{DoxyCompactList}\small\item\em Connect context to connection instance and return enabled callbacks. \end{DoxyCompactList}\item 
\mbox{\label{namespaceMilter_a991b1e2cee845a5e91b55345d5309c11}} 
def \textbf{ connect\+\_\+callback} (ctx, hostname, family, hostaddr, nr\+\_\+mask=P\+\_\+\+N\+R\+\_\+\+C\+O\+NN)
\begin{DoxyCompactList}\small\item\em Connect context if needed and invoke connect method. \end{DoxyCompactList}\item 
\mbox{\label{namespaceMilter_aacda23f972ebb12f0ba4364a868b85b8}} 
def \textbf{ close\+\_\+callback} (ctx)
\begin{DoxyCompactList}\small\item\em Disconnect milter\+Context and call close method. \end{DoxyCompactList}\item 
def \textbf{ dictfromlist} (args)
\begin{DoxyCompactList}\small\item\em Convert E\+S\+M\+TP parameters with values to a keyword dictionary. \end{DoxyCompactList}\item 
def \textbf{ param2dict} (str)
\begin{DoxyCompactList}\small\item\em Convert E\+S\+M\+TP parm list to keyword dictionary. \end{DoxyCompactList}\item 
def \textbf{ envcallback} (c, args)
\item 
def \textbf{ runmilter} (name, socketname, timeout=0, rmsock=True)
\begin{DoxyCompactList}\small\item\em Run the milter. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{namespaceMilter_a52a627e58830372ea605aa1cba4e577b}} 
string {\bfseries \+\_\+\+\_\+version\+\_\+\+\_\+} = \textquotesingle{}1.\+0.\+4\textquotesingle{}
\item 
\mbox{\label{namespaceMilter_a353c6bd4cea8161f11341ed69a540e25}} 
{\bfseries \+\_\+seq\+\_\+lock} = thread.\+allocate\+\_\+lock()
\item 
\mbox{\label{namespaceMilter_a0e11e271e13282c95839a8fc693c61fd}} 
int {\bfseries \+\_\+seq} = 0
\item 
dictionary {\bfseries O\+P\+T\+I\+O\+N\+A\+L\+\_\+\+C\+A\+L\+L\+B\+A\+C\+KS}
\item 
dictionary {\bfseries M\+A\+C\+R\+O\+\_\+\+C\+A\+L\+L\+B\+A\+C\+KS}
\item 
\mbox{\label{namespaceMilter_a39ab0eddcf476183b04e7c876f4f658d}} 
{\bfseries R} = re.\+compile(r\textquotesingle{}\%+\textquotesingle{})
\item 
\textbf{ factory} = \textbf{ Milter}
\begin{DoxyCompactList}\small\item\em The milter connection factory This factory method is called for each connection to create the python object that tracks the connection. \end{DoxyCompactList}\item 
\mbox{\label{namespaceMilter_a27f56b15dbe8a30a22df763820c29378}} 
{\bfseries \+\_\+\+\_\+all\+\_\+\+\_\+} = globals().copy()
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
A thin OO wrapper for the milter module.

Clients generally subclass \doxyref{Milter.\+Base}{p.}{classMilter_1_1Base} and define callback methods.

\begin{DoxyAuthor}{Author}
Stuart D. Gathman {\texttt{ stuart@bmsi.\+com}} Copyright 2001,2009 Business Management Systems, Inc. This code is under the G\+NU General Public License. See C\+O\+P\+Y\+I\+NG for details. 
\end{DoxyAuthor}


\doxysubsection{Function Documentation}
\mbox{\label{namespaceMilter_a70614463afdd03aa7fefafde049ce003}} 
\index{Milter@{Milter}!dictfromlist@{dictfromlist}}
\index{dictfromlist@{dictfromlist}!Milter@{Milter}}
\doxysubsubsection{dictfromlist()}
{\footnotesize\ttfamily def Milter.\+dictfromlist (\begin{DoxyParamCaption}\item[{}]{args }\end{DoxyParamCaption})}



Convert E\+S\+M\+TP parameters with values to a keyword dictionary. 

\begin{DoxyRefDesc}{Deprecated}
\item[\textbf{ Deprecated}]You probably want \doxyref{Milter.\+param2dict}{p.}{namespaceMilter_aa7a286dc2615af8a18b4ce61142b69c7} instead. \end{DoxyRefDesc}
\mbox{\label{namespaceMilter_adb642b2896800154bfd09a87714270f3}} 
\index{Milter@{Milter}!enable\_protocols@{enable\_protocols}}
\index{enable\_protocols@{enable\_protocols}!Milter@{Milter}}
\doxysubsubsection{enable\_protocols()}
{\footnotesize\ttfamily def Milter.\+enable\+\_\+protocols (\begin{DoxyParamCaption}\item[{}]{klass,  }\item[{}]{mask }\end{DoxyParamCaption})}



Class decorator to enable optional protocol steps. 

P\+\_\+\+S\+K\+IP is enabled by default when supported, but applications may wish to enable P\+\_\+\+H\+D\+R\+\_\+\+L\+E\+A\+D\+S\+PC to send and receive the leading space of header continuation lines unchanged, and/or P\+\_\+\+R\+C\+P\+T\+\_\+\+R\+EJ to have recipients detected as invalid by the M\+TA passed to the envcrpt callback.

Applications may want to check whether the protocol is actually supported by the M\+TA in use. \doxyref{Base.\+\_\+protocol}{p.}{classMilter_1_1Base_a2b029cd0e1e8a56340a09cb64425f024} is a bitmask of protocol options negotiated. So, for instance, if {\ttfamily self.\+\_\+protocol \& Milter.\+P\+\_\+\+R\+C\+P\+T\+\_\+\+R\+EJ} is true, then that feature was successfully negotiated with the M\+TA and the application will see recipients the M\+TA has flagged as invalid.

Sample use\+: 
\begin{DoxyPre}
 class myMilter(\doxyref{Milter.Base}{p.}{classMilter_1_1Base}):
   def envrcpt(self,to,*params):
     return Milter.CONTINUE
 myMilter = \doxyref{Milter.enable\_protocols}{p.}{namespaceMilter_adb642b2896800154bfd09a87714270f3}(myMilter,Milter.P\_RCPT\_REJ)
 \end{DoxyPre}
 \begin{DoxySince}{Since}
0.\+9.\+3 
\end{DoxySince}

\begin{DoxyParams}{Parameters}
{\em klass} & the milter application class to modify \\
\hline
{\em mask} & a bitmask of protocol steps to enable \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the modified milter class 
\end{DoxyReturn}


Referenced by header\+\_\+leading\+\_\+space(), and rejected\+\_\+recipients().

\mbox{\label{namespaceMilter_a5e8bd5026774a96120d083007a5d4d73}} 
\index{Milter@{Milter}!envcallback@{envcallback}}
\index{envcallback@{envcallback}!Milter@{Milter}}
\doxysubsubsection{envcallback()}
{\footnotesize\ttfamily def Milter.\+envcallback (\begin{DoxyParamCaption}\item[{}]{c,  }\item[{}]{args }\end{DoxyParamCaption})}

\begin{DoxyVerb}Call function c with ESMTP parms converted to keyword parameters.
Can be used in the envfrom and/or envrcpt callbacks to process
ESMTP parameters as python keyword parameters.\end{DoxyVerb}
 \mbox{\label{namespaceMilter_a7499675835bbccdb9512199a0b170bc2}} 
\index{Milter@{Milter}!header\_leading\_space@{header\_leading\_space}}
\index{header\_leading\_space@{header\_leading\_space}!Milter@{Milter}}
\doxysubsubsection{header\_leading\_space()}
{\footnotesize\ttfamily def Milter.\+header\+\_\+leading\+\_\+space (\begin{DoxyParamCaption}\item[{}]{klass }\end{DoxyParamCaption})}



\doxyref{Milter}{p.}{namespaceMilter} leading space on headers. 

A class decorator that calls \doxyref{enable\+\_\+protocols()}{p.}{namespaceMilter_adb642b2896800154bfd09a87714270f3} with the P\+\_\+\+H\+D\+R\+\_\+\+L\+E\+A\+D\+S\+PC flag. By default, header continuation lines are collected and joined before getting sent to a milter. Headers modified or added by the milter are folded by the M\+TA as necessary according to its own standards. With this flag, header continuation lines are preserved with their newlines and leading space. In addition, header folding done by the milter is preserved as well. Use like this with python-\/2.\+6 and later\+: 
\begin{DoxyPre}
 @\doxyref{Milter.header\_leading\_space}{p.}{namespaceMilter_a7499675835bbccdb9512199a0b170bc2}
 class myMilter(\doxyref{Milter.Base}{p.}{classMilter_1_1Base}):
   def header(self,hname,value):
     return Milter.CONTINUE
 \end{DoxyPre}
 \begin{DoxySince}{Since}
0.\+9.\+5 
\end{DoxySince}

\begin{DoxyParams}{Parameters}
{\em klass} & the milter application class to modify \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the modified milter class 
\end{DoxyReturn}


References enable\+\_\+protocols().

\mbox{\label{namespaceMilter_a4bcf5eccbf8694a1c259fa6681557d6b}} 
\index{Milter@{Milter}!nocallback@{nocallback}}
\index{nocallback@{nocallback}!Milter@{Milter}}
\doxysubsubsection{nocallback()}
{\footnotesize\ttfamily def Milter.\+nocallback (\begin{DoxyParamCaption}\item[{}]{func }\end{DoxyParamCaption})}



Function decorator to disable callback methods. 

If the M\+TA supports it, tells the M\+TA not to invoke this callback, increasing efficiency. All the callbacks (except negotiate) are disabled in \doxyref{Milter.\+Base}{p.}{classMilter_1_1Base}, and overriding them reenables the callback. An application may need to use @nocallback when it extends another milter and wants to disable a callback again. The disabled method should still return Milter.\+C\+O\+N\+T\+I\+N\+UE, in case the M\+TA does not support protocol negotiation, and for when called from a test harness. \begin{DoxySince}{Since}
0.\+9.\+2 
\end{DoxySince}
\mbox{\label{namespaceMilter_a5bc0cfa03c567347b622acda6f6b6d42}} 
\index{Milter@{Milter}!noreply@{noreply}}
\index{noreply@{noreply}!Milter@{Milter}}
\doxysubsubsection{noreply()}
{\footnotesize\ttfamily def Milter.\+noreply (\begin{DoxyParamCaption}\item[{}]{func }\end{DoxyParamCaption})}



Function decorator to disable callback reply. 

If the M\+TA supports it, tells the M\+TA not to wait for a reply from this callback, and assume C\+O\+N\+T\+I\+N\+UE. The method should still return C\+O\+N\+T\+I\+N\+UE in case the M\+TA does not support protocol negotiation. The decorator arranges to change the return code to N\+O\+R\+E\+P\+LY when supported by the M\+TA. \begin{DoxySince}{Since}
0.\+9.\+2 
\end{DoxySince}
\mbox{\label{namespaceMilter_aa7a286dc2615af8a18b4ce61142b69c7}} 
\index{Milter@{Milter}!param2dict@{param2dict}}
\index{param2dict@{param2dict}!Milter@{Milter}}
\doxysubsubsection{param2dict()}
{\footnotesize\ttfamily def Milter.\+param2dict (\begin{DoxyParamCaption}\item[{}]{str }\end{DoxyParamCaption})}



Convert E\+S\+M\+TP parm list to keyword dictionary. 

Params with no value are set to None in the dictionary. \begin{DoxySince}{Since}
0.\+9.\+3 
\end{DoxySince}

\begin{DoxyParams}{Parameters}
{\em str} & list of param strings of the form \char`\"{}\+N\+A\+M\+E\char`\"{} or \char`\"{}\+N\+A\+M\+E=\+V\+A\+L\+U\+E\char`\"{} \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a dictionary of E\+S\+M\+TP param names and values 
\end{DoxyReturn}
\mbox{\label{namespaceMilter_a51b93684e65400f11b94b517bead1552}} 
\index{Milter@{Milter}!rejected\_recipients@{rejected\_recipients}}
\index{rejected\_recipients@{rejected\_recipients}!Milter@{Milter}}
\doxysubsubsection{rejected\_recipients()}
{\footnotesize\ttfamily def Milter.\+rejected\+\_\+recipients (\begin{DoxyParamCaption}\item[{}]{klass }\end{DoxyParamCaption})}



\doxyref{Milter}{p.}{namespaceMilter} rejected recipients. 

A class decorator that calls \doxyref{enable\+\_\+protocols()}{p.}{namespaceMilter_adb642b2896800154bfd09a87714270f3} with the P\+\_\+\+R\+C\+P\+T\+\_\+\+R\+EJ flag. By default, the M\+TA does not pass recipients that it knows are invalid on to the milter. This decorator enables a milter app to see all recipients if supported by the M\+TA. Use like this with python-\/2.\+6 and later\+: 
\begin{DoxyPre}
 @\doxyref{Milter.rejected\_recipients}{p.}{namespaceMilter_a51b93684e65400f11b94b517bead1552}
 class myMilter(\doxyref{Milter.Base}{p.}{classMilter_1_1Base}):
   def envrcpt(self,to,*params):
     return Milter.CONTINUE
 \end{DoxyPre}
 \begin{DoxySince}{Since}
0.\+9.\+5 
\end{DoxySince}

\begin{DoxyParams}{Parameters}
{\em klass} & the milter application class to modify \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the modified milter class 
\end{DoxyReturn}


References enable\+\_\+protocols().

\mbox{\label{namespaceMilter_a2a9ef4e7c479795d911767ebf66b073f}} 
\index{Milter@{Milter}!runmilter@{runmilter}}
\index{runmilter@{runmilter}!Milter@{Milter}}
\doxysubsubsection{runmilter()}
{\footnotesize\ttfamily def Milter.\+runmilter (\begin{DoxyParamCaption}\item[{}]{name,  }\item[{}]{socketname,  }\item[{}]{timeout = {\ttfamily 0},  }\item[{}]{rmsock = {\ttfamily True} }\end{DoxyParamCaption})}



Run the milter. 


\begin{DoxyParams}{Parameters}
{\em name} & the name of the milter known to the M\+TA \\
\hline
{\em socketname} & the socket to be passed to \doxyref{milter.\+setconn()}{p.}{namespacemilter_a47dedd3e5972a865bcfaa5163eb481cb} \\
\hline
{\em timeout} & the time in secs the M\+TA should wait for a response before considering this milter dead \\
\hline
\end{DoxyParams}


References milter.\+getversion(), milter.\+main(), milter.\+opensocket(), milter.\+register(), milter.\+setconn(), and milter.\+settimeout().

\mbox{\label{namespaceMilter_aad860a9bcc323b935a25b9528fec6398}} 
\index{Milter@{Milter}!symlist@{symlist}}
\index{symlist@{symlist}!Milter@{Milter}}
\doxysubsubsection{symlist()}
{\footnotesize\ttfamily def Milter.\+symlist (\begin{DoxyParamCaption}\item[{$\ast$}]{syms }\end{DoxyParamCaption})}



Function decorator to set macros used in a callback. 

By default, the M\+TA sends all macros defined for a callback. If some or all of these are unused, the bandwidth can be saved by listing the ones that are used. \begin{DoxySince}{Since}
1.\+0.\+2 
\end{DoxySince}
\mbox{\label{namespaceMilter_ad789f93f62d6c9e96fdd9be997204cf0}} 
\index{Milter@{Milter}!uniqueID@{uniqueID}}
\index{uniqueID@{uniqueID}!Milter@{Milter}}
\doxysubsubsection{uniqueID()}
{\footnotesize\ttfamily def Milter.\+unique\+ID (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}

\begin{DoxyVerb}Return a unique sequence number (incremented on each call).
\end{DoxyVerb}
 

\doxysubsection{Variable Documentation}
\mbox{\label{namespaceMilter_ad9d443c6e5b7fd46770435e7656e7d39}} 
\index{Milter@{Milter}!factory@{factory}}
\index{factory@{factory}!Milter@{Milter}}
\doxysubsubsection{factory}
{\footnotesize\ttfamily Milter.\+factory = \textbf{ Milter}}



The milter connection factory This factory method is called for each connection to create the python object that tracks the connection. 

It should return an object derived from \doxyref{Milter.\+Base}{p.}{classMilter_1_1Base}.

Note that since python is dynamic, this variable can be changed while the milter is running\+: for instance, to a new subclass based on a change in configuration. 

Referenced by connect\+\_\+callback(), and negotiate\+\_\+callback().

\mbox{\label{namespaceMilter_ae2bfeab3e33ceed9d2104017a97a506c}} 
\index{Milter@{Milter}!MACRO\_CALLBACKS@{MACRO\_CALLBACKS}}
\index{MACRO\_CALLBACKS@{MACRO\_CALLBACKS}!Milter@{Milter}}
\doxysubsubsection{MACRO\_CALLBACKS}
{\footnotesize\ttfamily dictionary Milter.\+M\+A\+C\+R\+O\+\_\+\+C\+A\+L\+L\+B\+A\+C\+KS}

{\bfseries Initial value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 =  \{}
\DoxyCodeLine{2   \textcolor{stringliteral}{'connect'}: M\_CONNECT,}
\DoxyCodeLine{3   \textcolor{stringliteral}{'hello'}: M\_HELO, \textcolor{stringliteral}{'envfrom'}: M\_ENVFROM, \textcolor{stringliteral}{'envrcpt'}: M\_ENVRCPT,}
\DoxyCodeLine{4   \textcolor{stringliteral}{'data'}: M\_DATA, \textcolor{stringliteral}{'eom'}: M\_EOM, \textcolor{stringliteral}{'eoh'}: M\_EOH}
\DoxyCodeLine{5 \}}

\end{DoxyCode}
\mbox{\label{namespaceMilter_afabb800c9ae9018dfa1d176710fe9386}} 
\index{Milter@{Milter}!OPTIONAL\_CALLBACKS@{OPTIONAL\_CALLBACKS}}
\index{OPTIONAL\_CALLBACKS@{OPTIONAL\_CALLBACKS}!Milter@{Milter}}
\doxysubsubsection{OPTIONAL\_CALLBACKS}
{\footnotesize\ttfamily dictionary Milter.\+O\+P\+T\+I\+O\+N\+A\+L\+\_\+\+C\+A\+L\+L\+B\+A\+C\+KS\hspace{0.3cm}{\ttfamily [private]}}

{\bfseries Initial value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 =  \{}
\DoxyCodeLine{2   \textcolor{stringliteral}{'connect'}:(P\_NR\_CONN,P\_NOCONNECT),}
\DoxyCodeLine{3   \textcolor{stringliteral}{'hello'}:(P\_NR\_HELO,P\_NOHELO),}
\DoxyCodeLine{4   \textcolor{stringliteral}{'envfrom'}:(P\_NR\_MAIL,P\_NOMAIL),}
\DoxyCodeLine{5   \textcolor{stringliteral}{'envrcpt'}:(P\_NR\_RCPT,P\_NORCPT),}
\DoxyCodeLine{6   \textcolor{stringliteral}{'data'}:(P\_NR\_DATA,P\_NODATA),}
\DoxyCodeLine{7   \textcolor{stringliteral}{'unknown'}:(P\_NR\_UNKN,P\_NOUNKNOWN),}
\DoxyCodeLine{8   \textcolor{stringliteral}{'eoh'}:(P\_NR\_EOH,P\_NOEOH),}
\DoxyCodeLine{9   \textcolor{stringliteral}{'body'}:(P\_NR\_BODY,P\_NOBODY),}
\DoxyCodeLine{10   \textcolor{stringliteral}{'header'}:(P\_NR\_HDR,P\_NOHDRS)}
\DoxyCodeLine{11 \}}

\end{DoxyCode}
