summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorklm1998-08-01 19:12:19 +0000
committerklm1998-08-01 19:12:19 +0000
commit92956285d99dea138375be5e9c56c707d6f8dd1f (patch)
treef23c13f98c316b56978e5e85724c3eba0905d283
parent62f9dfdaccb6e5c6f8a2c779531dac9660650c3d (diff)
downloadmailman-92956285d99dea138375be5e9c56c707d6f8dd1f.tar.gz
mailman-92956285d99dea138375be5e9c56c707d6f8dd1f.tar.zst
mailman-92956285d99dea138375be5e9c56c707d6f8dd1f.zip
TrySMTPDelivery: The queueing activity had to be more discriminating,
or else failures, like bad local recipients, would remain on the queue forever, and cause repeat deliveries. (I believe this is part of the problem behind the repeats we're seeing - but i'm not convinced it's all of it.) To fix, i made it so only partcicular exceptions - currently socket.error, for absent SMTP listener - cause items to be left on queue. Otherwise it falls through to a blanket except which discards the item, leaving a note in the error log to that effect. *** I think where the info should go back to the maillist structure, to, e.g., disable the recipient, or whatever. However, this is happening in a forked process, so we cannot use an exception, and the routine itself doesn't, and shouldn't know which the list is.
-rw-r--r--Mailman/Utils.py31
1 files changed, 26 insertions, 5 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py
index b143d66e8..04ca8b60f 100644
--- a/Mailman/Utils.py
+++ b/Mailman/Utils.py
@@ -33,7 +33,6 @@ import fcntl
import random
import mm_cfg
-
# Valid toplevel domains for when we check the validity of an email address.
valid_toplevels = ["com", "edu", "gov", "int", "mil", "net", "org",
@@ -168,6 +167,7 @@ def DeliverToUser(msg, recipient, add_headers=[]):
# foreground*. If the errorsto happens to be the list owner for a list
# that is doing the send - and holding a lock - then the delivery will
# hang pending release of the lock - deadlock.
+
if os.fork():
return
sender = msg.GetSender()
@@ -194,17 +194,38 @@ def DeliverToUser(msg, recipient, add_headers=[]):
os._exit(0)
def TrySMTPDelivery(recipient, sender, text, queue_entry):
+ import socket
import smtplib
+ import OutgoingQueue
+
try:
con = smtplib.SmtpConnection(mm_cfg.SMTPHOST)
con.helo(mm_cfg.DEFAULT_HOST_NAME)
con.send(to=recipient,frm=sender,text=text)
con.quit()
- import OutgoingQueue
OutgoingQueue.dequeueMessage(queue_entry)
- finally:
-# except: # Todo: This might want to handle special cases.
- pass # Just try again later.
+
+ # Any exceptions that warrant leaving the message on the queue should
+ # be identified here. Otherwise we fall through to the blanket
+ # 'except', which does *not* leave the message queued.
+
+ except socket.error:
+ # MTA not responding - leave on queue for later.
+ pass
+
+ except:
+ # Delivery failed for anticipated reason - *don't* leave message
+ # queued, or it may stay, under delivery attempts, forever!
+ OutgoingQueue.dequeueMessage(queue_entry)
+ # XXX Here may be the place to get the failure info back to the
+ # list object, so it can disable the recipient, etc. But how?
+ import sys
+ e = sys.exc_info()
+ from Logging.Logger import Logger
+ Logger("error").write(
+ "TrySMTPDelivery: bad smtp delivery to %s\n\t%s/%s\n"
+ % (recipient, e[0], e[1]))
+
def QuotePeriods(text):
return string.join(string.split(text, '\n.\n'), '\n .\n')