\doxysection{Milter.\+dsn Namespace Reference}
\label{namespaceMilter_1_1dsn}\index{Milter.dsn@{Milter.dsn}}
\doxysubsection*{Classes}
\begin{DoxyCompactItemize}
\item 
class \textbf{ Vars}
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
def \textbf{ send\+\_\+dsn} (mailfrom, receiver, msg=None, timeout=600, session=None, ourfrom=\textquotesingle{}\textquotesingle{})
\begin{DoxyCompactList}\small\item\em Send D\+SN. \end{DoxyCompactList}\item 
def \textbf{ create\+\_\+msg} (v, rcptlist=None, origmsg=None, template=None)
\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
{\bfseries q}
\item 
\mbox{\label{namespaceMilter_1_1dsn_a82d40b2aed892ae45a5141afc0fc6dca}} 
{\bfseries result}
\item 
\mbox{\label{namespaceMilter_1_1dsn_a243617d6c6c4af2994659efdf1a8dba7}} 
{\bfseries perm\+\_\+error}
\item 
def {\bfseries msg}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Support D\+S\+Ns and Call\+Back\+Validations (C\+BV).

A Delivery Status Notification (bounce) is sent to the envelope sender (original M\+A\+IL F\+R\+OM) with a null M\+A\+IL F\+R\+OM ($<$$>$) to notify the original sender \# of delays or problems with delivery. A Callback Validation starts the D\+SN process, but stops before issuing the D\+A\+TA command. The purpose is to check whether the envelope recipient is accepted (and is therefore a valid email). The null M\+A\+IL F\+R\+OM tells the remote M\+TA to never reply according to R\+F\+C2821 (but some braindead M\+T\+As reply anyway, of course).

Milters should cache C\+BV results and should avoid sending D\+S\+Ns unless the sender is authenticated somehow (e.\+g. S\+PF Pass). However, when email is quarantined, and is not known to be a forgery, sending a D\+SN is better than silently disappearing, and a D\+SN is better than sending a normal message as notification -\/ because M\+A\+IL F\+R\+OM signing schemes can reject bounces of forged emails. Whatever you do, don\textquotesingle{}t copy those assinine commercial filters that send a normal message to notify you that some virus is forging your email.

{\bfseries{D\+S\+Ns should {\itshape only} be sent to M\+A\+IL F\+R\+OM addresses.}} Never send a D\+SN or use a null M\+A\+IL F\+R\+OM with an email address obtained from anywhere else. 

\doxysubsection{Function Documentation}
\mbox{\label{namespaceMilter_1_1dsn_aa713bf34ec804fe8dd24fb4aa7c83141}} 
\index{Milter.dsn@{Milter.dsn}!create\_msg@{create\_msg}}
\index{create\_msg@{create\_msg}!Milter.dsn@{Milter.dsn}}
\doxysubsubsection{create\_msg()}
{\footnotesize\ttfamily def Milter.\+dsn.\+create\+\_\+msg (\begin{DoxyParamCaption}\item[{}]{v,  }\item[{}]{rcptlist = {\ttfamily None},  }\item[{}]{origmsg = {\ttfamily None},  }\item[{}]{template = {\ttfamily None} }\end{DoxyParamCaption})}

\begin{DoxyVerb}Create a DSN message from a template.  Template must be '\n' separated.
   v - an object whose attributes are used for substitutions.  Must
     have sender and receiver attributes at a minimum.
   rcptlist - used to set v.rcpt if given
   origmsg - used to set v.subject and v.spf_result if given
   template - a '\n' separated string with python '%(name)s' substitutions.
\end{DoxyVerb}
 \mbox{\label{namespaceMilter_1_1dsn_acbe09f59aaa4ca067189f08e9f2d38d6}} 
\index{Milter.dsn@{Milter.dsn}!send\_dsn@{send\_dsn}}
\index{send\_dsn@{send\_dsn}!Milter.dsn@{Milter.dsn}}
\doxysubsubsection{send\_dsn()}
{\footnotesize\ttfamily def Milter.\+dsn.\+send\+\_\+dsn (\begin{DoxyParamCaption}\item[{}]{mailfrom,  }\item[{}]{receiver,  }\item[{}]{msg = {\ttfamily None},  }\item[{}]{timeout = {\ttfamily 600},  }\item[{}]{session = {\ttfamily None},  }\item[{}]{ourfrom = {\ttfamily \textquotesingle{}\textquotesingle{}} }\end{DoxyParamCaption})}



Send D\+SN. 

Try the published MX names in order, rejecting obviously bogus entries (like {\ttfamily localhost}). 
\begin{DoxyParams}{Parameters}
{\em mailfrom} & the original sender we are notifying or validating \\
\hline
{\em receiver} & the H\+E\+LO name of the M\+TA we are sending the D\+SN on behalf of. Be sure to send from an IP that matches the H\+E\+LO. \\
\hline
{\em msg} & the D\+SN message in R\+F\+C2822 format, or None for C\+BV. \\
\hline
{\em timeout} & total seconds to wait for a response from an MX \\
\hline
{\em session} & \doxyref{Milter.\+dns.\+Session}{p.}{classMilter_1_1dns_1_1Session} object from current incoming mail session to reuse its cache, or None to create a fresh one. \\
\hline
{\em ourfrom} & set to a valid email to send a normal notification from, or to validate emails not obtained from M\+A\+IL F\+R\+OM. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
None on success or (status\+\_\+code,msg) on failure. \begin{DoxyVerb}Send DSN.  If msg is None, do callback verification.
   Mailfrom is original sender we are sending DSN or CBV to.
   Receiver is the MTA sending the DSN.
   Return None for success or (code,msg) for failure.\end{DoxyVerb}
 
\end{DoxyReturn}


\doxysubsection{Variable Documentation}
\mbox{\label{namespaceMilter_1_1dsn_a3b771fd4a441cb97f868e51b1aec0632}} 
\index{Milter.dsn@{Milter.dsn}!msg@{msg}}
\index{msg@{msg}!Milter.dsn@{Milter.dsn}}
\doxysubsubsection{msg}
{\footnotesize\ttfamily def Milter.\+dsn.\+msg}

{\bfseries Initial value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 =  create\_msg(q,[\textcolor{stringliteral}{'charlie@example.com'}],\textcolor{keywordtype}{None},}
\DoxyCodeLine{2 }
\DoxyCodeLine{3   )}

\end{DoxyCode}
\mbox{\label{namespaceMilter_1_1dsn_a2776201312f8aa18d3e08e111e243e1c}} 
\index{Milter.dsn@{Milter.dsn}!q@{q}}
\index{q@{q}!Milter.dsn@{Milter.dsn}}
\doxysubsubsection{q}
{\footnotesize\ttfamily Milter.\+dsn.\+q}

{\bfseries Initial value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 =  spf.query(\textcolor{stringliteral}{'192.168.9.50'},}
\DoxyCodeLine{2   \textcolor{stringliteral}{'SRS0=pmeHL=RH==stuart@example.com'},}
\DoxyCodeLine{3   \textcolor{stringliteral}{'red.example.com'},receiver=\textcolor{stringliteral}{'mail.example.com'})}

\end{DoxyCode}
