[Python-checkins] bpo-35800: Remove smtpd.MailmanProxy since 3.11 (GH-26617)

corona10 webhook-mailer at python.org
Wed Jun 9 19:12:51 EDT 2021


https://github.com/python/cpython/commit/309ab616020f8504ced8ca64f7d7abc2df25a37f
commit: 309ab616020f8504ced8ca64f7d7abc2df25a37f
branch: main
author: Dong-hee Na <donghee.na at python.org>
committer: corona10 <donghee.na92 at gmail.com>
date: 2021-06-10T08:12:41+09:00
summary:

bpo-35800: Remove smtpd.MailmanProxy since 3.11 (GH-26617)

files:
A Misc/NEWS.d/next/Library/2021-06-09-10-08-32.bpo-35800.3hmkWw.rst
M Doc/library/smtpd.rst
M Doc/whatsnew/3.11.rst
M Lib/smtpd.py

diff --git a/Doc/library/smtpd.rst b/Doc/library/smtpd.rst
index d84e74a8ceaaf..ae66e7e4596c6 100644
--- a/Doc/library/smtpd.rst
+++ b/Doc/library/smtpd.rst
@@ -142,24 +142,6 @@ PureProxy Objects
    chance to make you into an open relay, so please be careful.
 
 
-MailmanProxy Objects
---------------------
-
-
-.. class:: MailmanProxy(localaddr, remoteaddr)
-
-   .. deprecated-removed:: 3.9 3.11
-
-      :class:`MailmanProxy` is deprecated, it depends on a ``Mailman``
-      module which no longer exists and therefore is already broken.
-
-
-   Create a new pure proxy server. Arguments are as per :class:`SMTPServer`.
-   Everything will be relayed to *remoteaddr*, unless local mailman configurations
-   knows about an address, in which case it will be handled via mailman.  Note that
-   running this has a good chance to make you into an open relay, so please be
-   careful.
-
 SMTPChannel Objects
 -------------------
 
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index 00011278a51c4..dcab3679b200c 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -92,6 +92,13 @@ fractions
 Support :PEP:`515`-style initialization of :class:`~fractions.Fraction` from
 string.  (Contributed by Sergey B Kirpichev in :issue:`44258`.)
 
+
+Removed
+=======
+* :class:`smtpd.MailmanProxy` is now removed as it is unusable without
+  an external module, ``mailman``. (Contributed by Dong-hee Na in :issue:`35800`.)
+
+
 Optimizations
 =============
 
diff --git a/Lib/smtpd.py b/Lib/smtpd.py
index 1e2adc87a2bf2..d0536023e8401 100755
--- a/Lib/smtpd.py
+++ b/Lib/smtpd.py
@@ -60,13 +60,6 @@
 #   SMTP errors from the backend server at all.  This should be fixed
 #   (contributions are welcome!).
 #
-#   MailmanProxy - An experimental hack to work with GNU Mailman
-#   <www.list.org>.  Using this server as your real incoming smtpd, your
-#   mailhost will automatically recognize and accept mail destined to Mailman
-#   lists when those lists are created.  Every message not destined for a list
-#   gets forwarded to a real backend smtpd, as with PureProxy.  Again, errors
-#   are not handled correctly yet.
-#
 #
 # Author: Barry Warsaw <barry at python.org>
 #
@@ -91,7 +84,6 @@
 
 __all__ = [
     "SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy",
-    "MailmanProxy",
 ]
 
 program = sys.argv[0]
@@ -777,91 +769,6 @@ def _deliver(self, mailfrom, rcpttos, data):
         return refused
 
 
-class MailmanProxy(PureProxy):
-    def __init__(self, *args, **kwargs):
-        warn('MailmanProxy is deprecated and will be removed '
-             'in future', DeprecationWarning, 2)
-        if 'enable_SMTPUTF8' in kwargs and kwargs['enable_SMTPUTF8']:
-            raise ValueError("MailmanProxy does not support SMTPUTF8.")
-        super(PureProxy, self).__init__(*args, **kwargs)
-
-    def process_message(self, peer, mailfrom, rcpttos, data):
-        from io import StringIO
-        from Mailman import Utils
-        from Mailman import Message
-        from Mailman import MailList
-        # If the message is to a Mailman mailing list, then we'll invoke the
-        # Mailman script directly, without going through the real smtpd.
-        # Otherwise we'll forward it to the local proxy for disposition.
-        listnames = []
-        for rcpt in rcpttos:
-            local = rcpt.lower().split('@')[0]
-            # We allow the following variations on the theme
-            #   listname
-            #   listname-admin
-            #   listname-owner
-            #   listname-request
-            #   listname-join
-            #   listname-leave
-            parts = local.split('-')
-            if len(parts) > 2:
-                continue
-            listname = parts[0]
-            if len(parts) == 2:
-                command = parts[1]
-            else:
-                command = ''
-            if not Utils.list_exists(listname) or command not in (
-                    '', 'admin', 'owner', 'request', 'join', 'leave'):
-                continue
-            listnames.append((rcpt, listname, command))
-        # Remove all list recipients from rcpttos and forward what we're not
-        # going to take care of ourselves.  Linear removal should be fine
-        # since we don't expect a large number of recipients.
-        for rcpt, listname, command in listnames:
-            rcpttos.remove(rcpt)
-        # If there's any non-list destined recipients left,
-        print('forwarding recips:', ' '.join(rcpttos), file=DEBUGSTREAM)
-        if rcpttos:
-            refused = self._deliver(mailfrom, rcpttos, data)
-            # TBD: what to do with refused addresses?
-            print('we got refusals:', refused, file=DEBUGSTREAM)
-        # Now deliver directly to the list commands
-        mlists = {}
-        s = StringIO(data)
-        msg = Message.Message(s)
-        # These headers are required for the proper execution of Mailman.  All
-        # MTAs in existence seem to add these if the original message doesn't
-        # have them.
-        if not msg.get('from'):
-            msg['From'] = mailfrom
-        if not msg.get('date'):
-            msg['Date'] = time.ctime(time.time())
-        for rcpt, listname, command in listnames:
-            print('sending message to', rcpt, file=DEBUGSTREAM)
-            mlist = mlists.get(listname)
-            if not mlist:
-                mlist = MailList.MailList(listname, lock=0)
-                mlists[listname] = mlist
-            # dispatch on the type of command
-            if command == '':
-                # post
-                msg.Enqueue(mlist, tolist=1)
-            elif command == 'admin':
-                msg.Enqueue(mlist, toadmin=1)
-            elif command == 'owner':
-                msg.Enqueue(mlist, toowner=1)
-            elif command == 'request':
-                msg.Enqueue(mlist, torequest=1)
-            elif command in ('join', 'leave'):
-                # TBD: this is a hack!
-                if command == 'join':
-                    msg['Subject'] = 'subscribe'
-                else:
-                    msg['Subject'] = 'unsubscribe'
-                msg.Enqueue(mlist, torequest=1)
-
-
 class Options:
     setuid = True
     classname = 'PureProxy'
diff --git a/Misc/NEWS.d/next/Library/2021-06-09-10-08-32.bpo-35800.3hmkWw.rst b/Misc/NEWS.d/next/Library/2021-06-09-10-08-32.bpo-35800.3hmkWw.rst
new file mode 100644
index 0000000000000..d3bf596b75028
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-06-09-10-08-32.bpo-35800.3hmkWw.rst
@@ -0,0 +1,2 @@
+:class:`smtpd.MailmanProxy` is now removed as it is unusable without an
+external module, ``mailman``. Patch by Dong-hee Na.



More information about the Python-checkins mailing list