pymilter  1.0.5
Classes | Functions | Variables
Milter.dsn Namespace Reference

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

Classes

class  Vars
 

Functions

def send_dsn (mailfrom, receiver, msg=None, timeout=600, session=None, ourfrom='')
 Send DSN. More...
 
def create_msg (v, rcptlist=None, origmsg=None, template=None)
 

Variables

 q
 
 result
 
 perm_error
 
def 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

◆ create_msg()

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.

◆ send_dsn()

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
mailfromthe original sender we are notifying or validating
receiverthe HELO name of the MTA we are sending the DSN on behalf of. Be sure to send from an IP that matches the HELO.
msgthe DSN message in RFC2822 format, or None for CBV.
timeouttotal seconds to wait for a response from an MX
sessionMilter.dns.Session object from current incoming mail session to reuse its cache, or None to create a fresh one.
ourfromset 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

◆ msg

def Milter.dsn.msg
Initial value:
1 = create_msg(q,['charlie@example.com'],None,
2 
3  )

◆ q

Milter.dsn.q
Initial value:
1 = spf.query('192.168.9.50',
2  'SRS0=pmeHL=RH==stuart@example.com',
3  'red.example.com',receiver='mail.example.com')