Skip to content

Commit 309ab61

Browse files
authored
bpo-35800: Remove smtpd.MailmanProxy since 3.11 (GH-26617)
1 parent 457ce60 commit 309ab61

File tree

4 files changed

+9
-111
lines changed

4 files changed

+9
-111
lines changed

Doc/library/smtpd.rst

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -142,24 +142,6 @@ PureProxy Objects
142142
chance to make you into an open relay, so please be careful.
143143

144144

145-
MailmanProxy Objects
146-
--------------------
147-
148-
149-
.. class:: MailmanProxy(localaddr, remoteaddr)
150-
151-
.. deprecated-removed:: 3.9 3.11
152-
153-
:class:`MailmanProxy` is deprecated, it depends on a ``Mailman``
154-
module which no longer exists and therefore is already broken.
155-
156-
157-
Create a new pure proxy server. Arguments are as per :class:`SMTPServer`.
158-
Everything will be relayed to *remoteaddr*, unless local mailman configurations
159-
knows about an address, in which case it will be handled via mailman. Note that
160-
running this has a good chance to make you into an open relay, so please be
161-
careful.
162-
163145
SMTPChannel Objects
164146
-------------------
165147

Doc/whatsnew/3.11.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ fractions
9292
Support :PEP:`515`-style initialization of :class:`~fractions.Fraction` from
9393
string. (Contributed by Sergey B Kirpichev in :issue:`44258`.)
9494

95+
96+
Removed
97+
=======
98+
* :class:`smtpd.MailmanProxy` is now removed as it is unusable without
99+
an external module, ``mailman``. (Contributed by Dong-hee Na in :issue:`35800`.)
100+
101+
95102
Optimizations
96103
=============
97104

Lib/smtpd.py

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,6 @@
6060
# SMTP errors from the backend server at all. This should be fixed
6161
# (contributions are welcome!).
6262
#
63-
# MailmanProxy - An experimental hack to work with GNU Mailman
64-
# <www.list.org>. Using this server as your real incoming smtpd, your
65-
# mailhost will automatically recognize and accept mail destined to Mailman
66-
# lists when those lists are created. Every message not destined for a list
67-
# gets forwarded to a real backend smtpd, as with PureProxy. Again, errors
68-
# are not handled correctly yet.
69-
#
7063
#
7164
# Author: Barry Warsaw <barry@python.org>
7265
#
@@ -91,7 +84,6 @@
9184

9285
__all__ = [
9386
"SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy",
94-
"MailmanProxy",
9587
]
9688

9789
program = sys.argv[0]
@@ -777,91 +769,6 @@ def _deliver(self, mailfrom, rcpttos, data):
777769
return refused
778770

779771

780-
class MailmanProxy(PureProxy):
781-
def __init__(self, *args, **kwargs):
782-
warn('MailmanProxy is deprecated and will be removed '
783-
'in future', DeprecationWarning, 2)
784-
if 'enable_SMTPUTF8' in kwargs and kwargs['enable_SMTPUTF8']:
785-
raise ValueError("MailmanProxy does not support SMTPUTF8.")
786-
super(PureProxy, self).__init__(*args, **kwargs)
787-
788-
def process_message(self, peer, mailfrom, rcpttos, data):
789-
from io import StringIO
790-
from Mailman import Utils
791-
from Mailman import Message
792-
from Mailman import MailList
793-
# If the message is to a Mailman mailing list, then we'll invoke the
794-
# Mailman script directly, without going through the real smtpd.
795-
# Otherwise we'll forward it to the local proxy for disposition.
796-
listnames = []
797-
for rcpt in rcpttos:
798-
local = rcpt.lower().split('@')[0]
799-
# We allow the following variations on the theme
800-
# listname
801-
# listname-admin
802-
# listname-owner
803-
# listname-request
804-
# listname-join
805-
# listname-leave
806-
parts = local.split('-')
807-
if len(parts) > 2:
808-
continue
809-
listname = parts[0]
810-
if len(parts) == 2:
811-
command = parts[1]
812-
else:
813-
command = ''
814-
if not Utils.list_exists(listname) or command not in (
815-
'', 'admin', 'owner', 'request', 'join', 'leave'):
816-
continue
817-
listnames.append((rcpt, listname, command))
818-
# Remove all list recipients from rcpttos and forward what we're not
819-
# going to take care of ourselves. Linear removal should be fine
820-
# since we don't expect a large number of recipients.
821-
for rcpt, listname, command in listnames:
822-
rcpttos.remove(rcpt)
823-
# If there's any non-list destined recipients left,
824-
print('forwarding recips:', ' '.join(rcpttos), file=DEBUGSTREAM)
825-
if rcpttos:
826-
refused = self._deliver(mailfrom, rcpttos, data)
827-
# TBD: what to do with refused addresses?
828-
print('we got refusals:', refused, file=DEBUGSTREAM)
829-
# Now deliver directly to the list commands
830-
mlists = {}
831-
s = StringIO(data)
832-
msg = Message.Message(s)
833-
# These headers are required for the proper execution of Mailman. All
834-
# MTAs in existence seem to add these if the original message doesn't
835-
# have them.
836-
if not msg.get('from'):
837-
msg['From'] = mailfrom
838-
if not msg.get('date'):
839-
msg['Date'] = time.ctime(time.time())
840-
for rcpt, listname, command in listnames:
841-
print('sending message to', rcpt, file=DEBUGSTREAM)
842-
mlist = mlists.get(listname)
843-
if not mlist:
844-
mlist = MailList.MailList(listname, lock=0)
845-
mlists[listname] = mlist
846-
# dispatch on the type of command
847-
if command == '':
848-
# post
849-
msg.Enqueue(mlist, tolist=1)
850-
elif command == 'admin':
851-
msg.Enqueue(mlist, toadmin=1)
852-
elif command == 'owner':
853-
msg.Enqueue(mlist, toowner=1)
854-
elif command == 'request':
855-
msg.Enqueue(mlist, torequest=1)
856-
elif command in ('join', 'leave'):
857-
# TBD: this is a hack!
858-
if command == 'join':
859-
msg['Subject'] = 'subscribe'
860-
else:
861-
msg['Subject'] = 'unsubscribe'
862-
msg.Enqueue(mlist, torequest=1)
863-
864-
865772
class Options:
866773
setuid = True
867774
classname = 'PureProxy'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:class:`smtpd.MailmanProxy` is now removed as it is unusable without an
2+
external module, ``mailman``. Patch by Dong-hee Na.

0 commit comments

Comments
 (0)