From 0e1a2de41f3c98dc4578570a8dd97efff7143ae6 Mon Sep 17 00:00:00 2001 From: Stuart Gathman Date: Wed, 20 May 2009 20:08:44 +0000 Subject: [PATCH] Support non-DSN CBV (non-empty MAIL FROM) --- Milter/dsn.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Milter/dsn.py b/Milter/dsn.py index ce577b2..75be7ff 100644 --- a/Milter/dsn.py +++ b/Milter/dsn.py @@ -5,6 +5,9 @@ # Send DSNs, do call back verification, # and generate DSN messages from a template # $Log$ +# Revision 1.16 2007/09/25 01:24:59 customdesigned +# Allow arbitrary object, not just spf.query like, to provide data for create_msg +# # Revision 1.15 2007/09/24 20:13:26 customdesigned # Remove explicit spf dependency. # @@ -31,7 +34,7 @@ import Milter import time import dns -def send_dsn(mailfrom,receiver,msg=None,timeout=600,session=None): +def send_dsn(mailfrom,receiver,msg=None,timeout=600,session=None,ourfrom=''): """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. @@ -62,14 +65,14 @@ def send_dsn(mailfrom,receiver,msg=None,timeout=600,session=None): raise smtplib.SMTPHeloError(code, resp) if msg: try: - smtp.sendmail('<>',mailfrom,msg) + smtp.sendmail('<%s>'%ourfrom,mailfrom,msg) except smtplib.SMTPSenderRefused: # does not accept DSN, try postmaster (at the risk of mail loops) smtp.sendmail(''%receiver,mailfrom,msg) else: # CBV - code,resp = smtp.docmd('MAIL FROM: <>') + code,resp = smtp.docmd('MAIL FROM: <%s>'%ourfrom) if code != 250: - raise smtplib.SMTPSenderRefused(code, resp, '<>') + raise smtplib.SMTPSenderRefused(code, resp, '<%s>'%ourfrom) code,resp = smtp.rcpt(mailfrom) if code not in (250,251): return (code,resp) # permanent error