summaryrefslogtreecommitdiff
path: root/src/mailman/mta
diff options
context:
space:
mode:
authorBarry Warsaw2015-01-04 20:20:33 -0500
committerBarry Warsaw2015-01-04 20:20:33 -0500
commit4a612db8e89afed74173b93f3b64fa567b8417a3 (patch)
tree81a687d113079a25f93279f35c7eee2aa2572510 /src/mailman/mta
parent84af79988a4e916604cba31843778206efb7d1b8 (diff)
parentde181c1a40965a3a7deedd56a034a946f45b6984 (diff)
downloadmailman-4a612db8e89afed74173b93f3b64fa567b8417a3.tar.gz
mailman-4a612db8e89afed74173b93f3b64fa567b8417a3.tar.zst
mailman-4a612db8e89afed74173b93f3b64fa567b8417a3.zip
Merge the Python 3 branch.
Diffstat (limited to 'src/mailman/mta')
-rw-r--r--src/mailman/mta/aliases.py6
-rw-r--r--src/mailman/mta/base.py6
-rw-r--r--src/mailman/mta/bulk.py4
-rw-r--r--src/mailman/mta/connection.py3
-rw-r--r--src/mailman/mta/decorating.py3
-rw-r--r--src/mailman/mta/deliver.py3
-rw-r--r--src/mailman/mta/docs/authentication.rst2
-rw-r--r--src/mailman/mta/docs/bulk.rst9
-rw-r--r--src/mailman/mta/docs/connection.rst24
-rw-r--r--src/mailman/mta/exim4.py3
-rw-r--r--src/mailman/mta/null.py6
-rw-r--r--src/mailman/mta/personalized.py6
-rw-r--r--src/mailman/mta/postfix.py10
-rw-r--r--src/mailman/mta/tests/test_aliases.py6
-rw-r--r--src/mailman/mta/tests/test_connection.py51
-rw-r--r--src/mailman/mta/tests/test_delivery.py3
-rw-r--r--src/mailman/mta/verp.py3
17 files changed, 66 insertions, 82 deletions
diff --git a/src/mailman/mta/aliases.py b/src/mailman/mta/aliases.py
index 1b5f37d44..c309fb27b 100644
--- a/src/mailman/mta/aliases.py
+++ b/src/mailman/mta/aliases.py
@@ -17,17 +17,13 @@
"""Utility for generating all the aliases of a mailing list."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'MailTransportAgentAliases',
]
-from zope.interface import implementer
-
from mailman.interfaces.mta import IMailTransportAgentAliases
+from zope.interface import implementer
SUBDESTINATIONS = (
diff --git a/src/mailman/mta/base.py b/src/mailman/mta/base.py
index 7b9180ea3..8d7ca75af 100644
--- a/src/mailman/mta/base.py
+++ b/src/mailman/mta/base.py
@@ -17,9 +17,6 @@
"""Base delivery class."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'BaseDelivery',
'IndividualDelivery',
@@ -31,11 +28,10 @@ import socket
import logging
import smtplib
-from zope.interface import implementer
-
from mailman.config import config
from mailman.interfaces.mta import IMailTransportAgentDelivery
from mailman.mta.connection import Connection
+from zope.interface import implementer
log = logging.getLogger('mailman.smtp')
diff --git a/src/mailman/mta/bulk.py b/src/mailman/mta/bulk.py
index 4255e0c33..0dcd2cdf6 100644
--- a/src/mailman/mta/bulk.py
+++ b/src/mailman/mta/bulk.py
@@ -17,9 +17,6 @@
"""Bulk message delivery."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'BulkDelivery',
]
@@ -108,4 +105,3 @@ class BulkDelivery(BaseDelivery):
mlist, msg, msgdata, recipients)
refused.update(chunk_refused)
return refused
-
diff --git a/src/mailman/mta/connection.py b/src/mailman/mta/connection.py
index 8cf419545..9c49e5fb0 100644
--- a/src/mailman/mta/connection.py
+++ b/src/mailman/mta/connection.py
@@ -17,9 +17,6 @@
"""MTA connections."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'Connection',
]
diff --git a/src/mailman/mta/decorating.py b/src/mailman/mta/decorating.py
index ac99b3624..b4944d960 100644
--- a/src/mailman/mta/decorating.py
+++ b/src/mailman/mta/decorating.py
@@ -17,9 +17,6 @@
"""Individualized delivery with header/footer decorations."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'DecoratingDelivery',
'DecoratingMixin',
diff --git a/src/mailman/mta/deliver.py b/src/mailman/mta/deliver.py
index be04a48bd..f01390397 100644
--- a/src/mailman/mta/deliver.py
+++ b/src/mailman/mta/deliver.py
@@ -17,9 +17,6 @@
"""Generic delivery."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'deliver',
]
diff --git a/src/mailman/mta/docs/authentication.rst b/src/mailman/mta/docs/authentication.rst
index 94cd2c99e..f98c00e1f 100644
--- a/src/mailman/mta/docs/authentication.rst
+++ b/src/mailman/mta/docs/authentication.rst
@@ -60,7 +60,7 @@ But if the user name and password does not match, the connection will fail.
>>> response = bulk.deliver(
... mlist, msg, dict(recipients=['bperson@example.com']))
>>> dump_msgdata(response)
- bperson@example.com: (571, 'Bad authentication')
+ bperson@example.com: (571, b'Bad authentication')
>>> config.pop('auth')
diff --git a/src/mailman/mta/docs/bulk.rst b/src/mailman/mta/docs/bulk.rst
index f2a76229b..cd7873de1 100644
--- a/src/mailman/mta/docs/bulk.rst
+++ b/src/mailman/mta/docs/bulk.rst
@@ -332,7 +332,8 @@ recipients.
>>> failures = bulk.deliver(mlist, msg, msgdata)
>>> for address in sorted(failures):
- ... print(address, failures[address][0], failures[address][1])
+ ... print(address, failures[address][0],
+ ... failures[address][1].decode('ascii'))
aperson@example.org 500 Error: SMTPRecipientsRefused
bperson@example.org 500 Error: SMTPRecipientsRefused
cperson@example.org 500 Error: SMTPRecipientsRefused
@@ -350,7 +351,8 @@ Or there could be some other problem causing an SMTP response failure.
>>> failures = bulk.deliver(mlist, msg, msgdata)
>>> for address in sorted(failures):
- ... print(address, failures[address][0], failures[address][1])
+ ... print(address, failures[address][0],
+ ... failures[address][1].decode('ascii'))
aperson@example.org 450 Error: SMTPResponseException
bperson@example.org 450 Error: SMTPResponseException
cperson@example.org 450 Error: SMTPResponseException
@@ -361,7 +363,8 @@ Or there could be some other problem causing an SMTP response failure.
>>> failures = bulk.deliver(mlist, msg, msgdata)
>>> for address in sorted(failures):
- ... print(address, failures[address][0], failures[address][1])
+ ... print(address, failures[address][0],
+ ... failures[address][1].decode('ascii'))
aperson@example.org 500 Error: SMTPResponseException
bperson@example.org 500 Error: SMTPResponseException
cperson@example.org 500 Error: SMTPResponseException
diff --git a/src/mailman/mta/docs/connection.rst b/src/mailman/mta/docs/connection.rst
index a57a76bb9..f4e0d8107 100644
--- a/src/mailman/mta/docs/connection.rst
+++ b/src/mailman/mta/docs/connection.rst
@@ -75,30 +75,6 @@ will authenticate with the mail server after each new connection.
>>> reset()
>>> config.pop('auth')
-However, a bad user name or password generates an error.
-
- >>> config.push('auth', """
- ... [mta]
- ... smtp_user: baduser
- ... smtp_pass: badpass
- ... """)
-
- >>> connection = Connection(
- ... config.mta.smtp_host, int(config.mta.smtp_port), 0,
- ... config.mta.smtp_user, config.mta.smtp_pass)
- >>> connection.sendmail('anne@example.com', ['bart@example.com'], """\
- ... From: anne@example.com
- ... To: bart@example.com
- ... Subject: aardvarks
- ...
- ... """)
- Traceback (most recent call last):
- ...
- SMTPAuthenticationError: (571, 'Bad authentication')
-
- >>> reset()
- >>> config.pop('auth')
-
Sessions per connection
=======================
diff --git a/src/mailman/mta/exim4.py b/src/mailman/mta/exim4.py
index 1180b59eb..f25b12233 100644
--- a/src/mailman/mta/exim4.py
+++ b/src/mailman/mta/exim4.py
@@ -17,9 +17,6 @@
"""Creation/deletion hooks for the Exim4 MTA."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'LMTP',
]
diff --git a/src/mailman/mta/null.py b/src/mailman/mta/null.py
index 7a3624b31..3b9f6322e 100644
--- a/src/mailman/mta/null.py
+++ b/src/mailman/mta/null.py
@@ -20,17 +20,13 @@
Exim one example of an MTA that Just Works.
"""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'NullMTA',
]
-from zope.interface import implementer
-
from mailman.interfaces.mta import IMailTransportAgentLifecycle
+from zope.interface import implementer
diff --git a/src/mailman/mta/personalized.py b/src/mailman/mta/personalized.py
index 967bca68a..4ea9075a3 100644
--- a/src/mailman/mta/personalized.py
+++ b/src/mailman/mta/personalized.py
@@ -17,9 +17,6 @@
"""Personalized delivery."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'PersonalizedDelivery',
'PersonalizedMixin',
@@ -28,11 +25,10 @@ __all__ = [
from email.header import Header
from email.utils import formataddr
-from zope.component import getUtility
-
from mailman.interfaces.mailinglist import Personalization
from mailman.interfaces.usermanager import IUserManager
from mailman.mta.verp import VERPDelivery
+from zope.component import getUtility
diff --git a/src/mailman/mta/postfix.py b/src/mailman/mta/postfix.py
index bb709c6b4..f76a401fa 100644
--- a/src/mailman/mta/postfix.py
+++ b/src/mailman/mta/postfix.py
@@ -17,9 +17,6 @@
"""Creation/deletion hooks for the Postfix MTA."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'LMTP',
]
@@ -29,16 +26,15 @@ import os
import logging
from flufl.lock import Lock
-from operator import attrgetter
-from zope.component import getUtility
-from zope.interface import implementer
-
from mailman.config import config
from mailman.config.config import external_configuration
from mailman.interfaces.listmanager import IListManager
from mailman.interfaces.mta import (
IMailTransportAgentAliases, IMailTransportAgentLifecycle)
from mailman.utilities.datetime import now
+from operator import attrgetter
+from zope.component import getUtility
+from zope.interface import implementer
log = logging.getLogger('mailman.error')
diff --git a/src/mailman/mta/tests/test_aliases.py b/src/mailman/mta/tests/test_aliases.py
index 30c57e292..8eeeef2c8 100644
--- a/src/mailman/mta/tests/test_aliases.py
+++ b/src/mailman/mta/tests/test_aliases.py
@@ -17,9 +17,6 @@
"""Test the MTA file generating utility."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'TestAliases',
'TestPostfix',
@@ -31,13 +28,12 @@ import shutil
import tempfile
import unittest
-from zope.component import getUtility
-
from mailman.app.lifecycle import create_list
from mailman.interfaces.domain import IDomainManager
from mailman.interfaces.mta import IMailTransportAgentAliases
from mailman.mta.postfix import LMTP
from mailman.testing.layers import ConfigLayer
+from zope.component import getUtility
NL = '\n'
diff --git a/src/mailman/mta/tests/test_connection.py b/src/mailman/mta/tests/test_connection.py
new file mode 100644
index 000000000..74d0e537c
--- /dev/null
+++ b/src/mailman/mta/tests/test_connection.py
@@ -0,0 +1,51 @@
+# Copyright (C) 2014 by the Free Software Foundation, Inc.
+#
+# This file is part of GNU Mailman.
+#
+# GNU Mailman is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
+
+"""Test MTA connections."""
+
+__all__ = [
+ 'TestConnection',
+ ]
+
+
+import unittest
+
+from mailman.config import config
+from mailman.mta.connection import Connection
+from mailman.testing.layers import SMTPLayer
+from smtplib import SMTPAuthenticationError
+
+
+
+class TestConnection(unittest.TestCase):
+ layer = SMTPLayer
+
+ def test_authentication_error(self):
+ # Logging in to the MTA with a bad user name and password produces a
+ # 571 Bad Authentication error.
+ with self.assertRaises(SMTPAuthenticationError) as cm:
+ connection = Connection(
+ config.mta.smtp_host, int(config.mta.smtp_port), 0,
+ 'baduser', 'badpass')
+ connection.sendmail('anne@example.com', ['bart@example.com'], """\
+From: anne@example.com
+To: bart@example.com
+Subject: aardvarks
+
+""")
+ self.assertEqual(cm.exception.smtp_code, 571)
+ self.assertEqual(cm.exception.smtp_error, b'Bad authentication')
diff --git a/src/mailman/mta/tests/test_delivery.py b/src/mailman/mta/tests/test_delivery.py
index 0a910c13d..a2960f7cc 100644
--- a/src/mailman/mta/tests/test_delivery.py
+++ b/src/mailman/mta/tests/test_delivery.py
@@ -17,9 +17,6 @@
"""Test various aspects of email delivery."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'TestIndividualDelivery',
]
diff --git a/src/mailman/mta/verp.py b/src/mailman/mta/verp.py
index c3d1d0999..2d436b8cb 100644
--- a/src/mailman/mta/verp.py
+++ b/src/mailman/mta/verp.py
@@ -17,9 +17,6 @@
"""VERP delivery."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'VERPDelivery',
'VERPMixin',