diff options
| author | bwarsaw | 2001-12-16 06:23:14 +0000 |
|---|---|---|
| committer | bwarsaw | 2001-12-16 06:23:14 +0000 |
| commit | 22e43039ab1431ec588fcf12a533d7764553ed0f (patch) | |
| tree | 53bfbc24c3c49e7c392847c4618448a94ee25fa9 /Mailman | |
| parent | ef73a8f700cf43adb101640846e73206f70f9ad9 (diff) | |
| download | mailman-22e43039ab1431ec588fcf12a533d7764553ed0f.tar.gz mailman-22e43039ab1431ec588fcf12a533d7764553ed0f.tar.zst mailman-22e43039ab1431ec588fcf12a533d7764553ed0f.zip | |
Mailman re-uses connections to the SMTP server when delivering
multiple chunks. Marc Merlin points out that multi-transaction
sessions aren't handled correctly; this fixes the problem.
Specifically,
process(): In the non-threaded delivery stanza, be sure to quit the
connection when finished delivering instead of just closing it. This
ensures an SMTP QUIT command is sent.
threaded_deliver(): Same for thread-shared connections; quit instead
of just close.
deliver(): Get rid of the try/finally wrapper around the
conn.sendmail() call. We definitely don't want to QUIT the session
here.
Diffstat (limited to 'Mailman')
| -rw-r--r-- | Mailman/Handlers/SMTPDirect.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/Mailman/Handlers/SMTPDirect.py b/Mailman/Handlers/SMTPDirect.py index 90996c5ba..3eb95c182 100644 --- a/Mailman/Handlers/SMTPDirect.py +++ b/Mailman/Handlers/SMTPDirect.py @@ -98,7 +98,7 @@ def process(mlist, msg, msgdata): conn = smtplib.SMTP() for chunk in chunks: deliver(envsender, msgtext, chunk, refused, conn) - conn.close() + conn.quit() # Log the successful post t1 = time.time() d = MsgSafeDict(msg, {'time' : t1-t0, @@ -242,7 +242,7 @@ def threaded_deliver(envsender, msgtext, chunks, failures): for t, (threadfailures, conn) in threads.items(): t.join() failures.update(threadfailures) - conn.close() + conn.quit() # All threads have exited threads.clear() @@ -269,12 +269,8 @@ def deliver(envsender, msgtext, recips, failures, conn): # connected or not. :( if not getattr(conn, 'sock', 0): conn.connect(mm_cfg.SMTPHOST, mm_cfg.SMTPPORT) - try: - # make sure the connect happens, which won't be done by the - # constructor if SMTPHOST is false - refused = conn.sendmail(envsender, recips, msgtext) - finally: - conn.quit() + # Send the message + refused = conn.sendmail(envsender, recips, msgtext) except smtplib.SMTPRecipientsRefused, e: refused = e.recipients # MTA not responding, or other socket problems, or any other kind of |
