|
60 | 60 | # SMTP errors from the backend server at all. This should be fixed
|
61 | 61 | # (contributions are welcome!).
|
62 | 62 | #
|
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 |
| -# |
70 | 63 | #
|
71 | 64 | # Author: Barry Warsaw <barry@python.org>
|
72 | 65 | #
|
|
91 | 84 |
|
92 | 85 | __all__ = [
|
93 | 86 | "SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy",
|
94 |
| - "MailmanProxy", |
95 | 87 | ]
|
96 | 88 |
|
97 | 89 | program = sys.argv[0]
|
@@ -777,91 +769,6 @@ def _deliver(self, mailfrom, rcpttos, data):
|
777 | 769 | return refused
|
778 | 770 |
|
779 | 771 |
|
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 |
| - |
865 | 772 | class Options:
|
866 | 773 | setuid = True
|
867 | 774 | classname = 'PureProxy'
|
|
0 commit comments