\doxysection{Milter.\+dsn Namespace Reference}
\label{namespaceMilter_1_1dsn}\index{Milter.dsn@{Milter.dsn}}


Support DSNs and Call\+Back\+Validations (CBV).  


\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 DSN. \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 DSNs and Call\+Back\+Validations (CBV). 

A Delivery Status Notification (bounce) is sent to the envelope sender (original MAIL FROM) with a null MAIL FROM ($<$$>$) to notify the original sender \# of delays or problems with delivery. A Callback Validation starts the DSN process, but stops before issuing the DATA command. The purpose is to check whether the envelope recipient is accepted (and is therefore a valid email). The null MAIL FROM tells the remote MTA to never reply according to RFC2821 (but some braindead MTAs reply anyway, of course).

Milters should cache CBV results and should avoid sending DSNs unless the sender is authenticated somehow (e.\+g. SPF Pass). However, when email is quarantined, and is not known to be a forgery, sending a DSN is better than silently disappearing, and a DSN is better than sending a normal message as notification -\/ because MAIL FROM 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{DSNs should {\itshape only} be sent to MAIL FROM addresses.}} Never send a DSN or use a null MAIL FROM 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 DSN. 

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 HELO name of the MTA we are sending the DSN on behalf of. Be sure to send from an IP that matches the HELO. \\
\hline
{\em msg} & the DSN message in RFC2822 format, or None for CBV. \\
\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 MAIL FROM. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
None on success or (status\+\_\+code,msg) on failure.
\end{DoxyReturn}
\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}
 

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