Package Milter.dsn

Support DSNs and CallBackValidations (CBV). More...

Classes

class  Vars

Functions

def send_dsn
 Send DSN.
def create_msg

Variables

tuple q
tuple msg

Detailed Description

Support DSNs and CallBackValidations (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't copy those assinine commercial filters that send a normal message to notify you that some virus is forging your email.

DSNs should *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.


Function Documentation

def Milter.dsn.create_msg (   v,
  rcptlist = None,
  origmsg = None,
  template = None 
)
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.
def Milter.dsn.send_dsn (   mailfrom,
  receiver,
  msg = None,
  timeout = 600,
  session = None,
  ourfrom = '' 
)

Send DSN.

Try the published MX names in order, rejecting obviously bogus entries (like localhost).

Parameters:
mailfrom the original sender we are notifying or validating
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.
msg the DSN message in RFC2822 format, or None for CBV.
timeout total seconds to wait for a response from an MX
session Milter.dns.Session object from current incoming mail session to reuse its cache, or None to create a fresh one.
ourfrom set to a valid email to send a normal notification from, or to validate emails not obtained from MAIL FROM.
Returns:
None on success or (status_code,msg) on failure.
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.

Variable Documentation

tuple Milter::dsn.msg
Initial value:
create_msg(q,['charlie@example.com'],None,
"""From: postmaster@%(receiver)sTo: %(sender)sSubject: TestTest DSN template"""
  )
tuple Milter::dsn.q
Initial value:
spf.query('192.168.9.50',
  'SRS0=pmeHL=RH==stuart@example.com',
  'red.example.com',receiver='mail.example.com')

Generated on 11 Jul 2015 for pymilter by  doxygen 1.6.1