Handle DNS error sending DSN.

This commit is contained in:
Stuart Gathman
2007-03-03 18:19:40 +00:00
parent 806aa5a6de
commit d289822f42
2 changed files with 9 additions and 3 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ import milter
import thread
from milter import ACCEPT,CONTINUE,REJECT,DISCARD,TEMPFAIL, \
set_flags, setdbg, setbacklog, settimeout, \
set_flags, setdbg, setbacklog, settimeout, error, \
ADDHDRS, CHGBODY, ADDRCPT, DELRCPT, CHGHDRS, \
V1_ACTS, V2_ACTS, CURR_ACTS
+6
View File
@@ -5,6 +5,9 @@
# Send DSNs, do call back verification,
# and generate DSN messages from a template
# $Log$
# Revision 1.13 2007/01/04 18:01:11 customdesigned
# Do plain CBV when template missing.
#
# Revision 1.12 2006/07/26 16:37:35 customdesigned
# Support timeout.
#
@@ -28,8 +31,11 @@ def send_dsn(mailfrom,receiver,msg=None,timeout=600):
Receiver is the MTA sending the DSN.
Return None for success or (code,msg) for failure."""
user,domain = mailfrom.split('@')
try:
q = spf.query(None,None,None)
mxlist = q.dns(domain,'MX')
except spf.TempError:
return (450,'DNS Timeout: %s MX'%domain) # temp error
if not mxlist:
mxlist = (0,domain), # fallback to A record when no MX
else: