pymilter
1.0.5
|
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 |
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.
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
).
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. |
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.