diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/runners/docs/lmtp.rst | 60 | ||||
| -rw-r--r-- | src/mailman/runners/tests/test_lmtp.py | 31 |
2 files changed, 44 insertions, 47 deletions
diff --git a/src/mailman/runners/docs/lmtp.rst b/src/mailman/runners/docs/lmtp.rst index c2227581f..45e8a3453 100644 --- a/src/mailman/runners/docs/lmtp.rst +++ b/src/mailman/runners/docs/lmtp.rst @@ -20,7 +20,7 @@ Let's start a testable LMTP runner. It also helps to have a nice LMTP client. >>> lmtp = helpers.get_lmtp_client() - (220, '... Python LMTP runner 1.0') + (220, b'... Python LMTP runner 1.0') >>> lmtp.lhlo('remote.example.org') (250, ...) @@ -28,24 +28,8 @@ It also helps to have a nice LMTP client. Posting address =============== -If the mail server tries to send a message to a nonexistent mailing list, it -will get a 550 error. - - >>> lmtp.sendmail( - ... 'anne.person@example.com', - ... ['mylist@example.com'], """\ - ... From: anne.person@example.com - ... To: mylist@example.com - ... Subject: An interesting message - ... Message-ID: <aardvark> - ... - ... This is an interesting message. - ... """) - Traceback (most recent call last): - ... - SMTPDataError: (550, 'Requested action not taken: mailbox unavailable') - -Once the mailing list is created, the posting address is valid. +Once the mailing list is created, the posting address is valid, and messages +can be sent to the list. :: >>> create_list('mylist@example.com') @@ -82,7 +66,7 @@ queue. This is an interesting message. >>> dump_msgdata(messages[0].msgdata) _parsemsg : False - listname : mylist@example.com + listid : mylist.example.com original_size: ... to_list : True version : ... @@ -92,24 +76,8 @@ Sub-addresses ============= The LMTP server understands each of the list's sub-addreses, such as `-join`, -`-leave`, `-request` and so on. If the message is posted to an invalid -sub-address though, it is rejected. - - >>> lmtp.sendmail( - ... 'anne.person@example.com', - ... ['mylist-bogus@example.com'], """\ - ... From: anne.person@example.com - ... To: mylist-bogus@example.com - ... Subject: Help - ... Message-ID: <cow> - ... - ... Please help me. - ... """) - Traceback (most recent call last): - ... - SMTPDataError: (550, 'Requested action not taken: mailbox unavailable') - -But the message is accepted if posted to a valid sub-address. +`-leave`, `-request` and so on. The message is accepted if posted to a valid +sub-address. >>> lmtp.sendmail( ... 'anne.person@example.com', @@ -145,7 +113,7 @@ command queue for processing. Please help me. >>> dump_msgdata(messages[0].msgdata) _parsemsg : False - listname : mylist@example.com + listid : mylist.example.com original_size: ... subaddress : request version : ... @@ -172,7 +140,7 @@ A message to the `-bounces` address goes to the bounce processor. 1 >>> dump_msgdata(messages[0].msgdata) _parsemsg : False - listname : mylist@example.com + listid : mylist.example.com original_size: ... subaddress : bounces version : ... @@ -199,7 +167,7 @@ Confirmation messages go to the command processor... 1 >>> dump_msgdata(messages[0].msgdata) _parsemsg : False - listname : mylist@example.com + listid : mylist.example.com original_size: ... subaddress : confirm version : ... @@ -221,7 +189,7 @@ Confirmation messages go to the command processor... 1 >>> dump_msgdata(messages[0].msgdata) _parsemsg : False - listname : mylist@example.com + listid : mylist.example.com original_size: ... subaddress : join version : ... @@ -240,7 +208,7 @@ Confirmation messages go to the command processor... 1 >>> dump_msgdata(messages[0].msgdata) _parsemsg : False - listname : mylist@example.com + listid : mylist.example.com original_size: ... subaddress : join version : ... @@ -262,7 +230,7 @@ Confirmation messages go to the command processor... 1 >>> dump_msgdata(messages[0].msgdata) _parsemsg : False - listname : mylist@example.com + listid : mylist.example.com original_size: ... subaddress : leave version : ... @@ -281,7 +249,7 @@ Confirmation messages go to the command processor... 1 >>> dump_msgdata(messages[0].msgdata) _parsemsg : False - listname : mylist@example.com + listid : mylist.example.com original_size: ... subaddress : leave version : ... @@ -307,7 +275,7 @@ Messages to the `-owner` address also go to the incoming processor. >>> dump_msgdata(messages[0].msgdata) _parsemsg : False envsender : noreply@example.com - listname : mylist@example.com + listid : mylist.example.com original_size: ... subaddress : owner to_owner : True diff --git a/src/mailman/runners/tests/test_lmtp.py b/src/mailman/runners/tests/test_lmtp.py index 0757ec22d..41a4f93e0 100644 --- a/src/mailman/runners/tests/test_lmtp.py +++ b/src/mailman/runners/tests/test_lmtp.py @@ -30,7 +30,6 @@ import smtplib import unittest from datetime import datetime - from mailman.config import config from mailman.app.lifecycle import create_list from mailman.database.transaction import transaction @@ -118,6 +117,36 @@ Message-ID: <ant> queue_directory = os.path.join(config.QUEUE_DIR, 'lmtp') self.assertFalse(os.path.isdir(queue_directory)) + def test_nonexistent_mailing_list(self): + # Trying to post to a nonexistent mailing list is an error. + with self.assertRaises(smtplib.SMTPDataError) as cm: + self._lmtp.sendmail('anne@example.com', + ['notalist@example.com'], """\ +From: anne.person@example.com +To: notalist@example.com +Subject: An interesting message +Message-ID: <aardvark> + +""") + self.assertEqual(cm.exception.smtp_code, 550) + self.assertEqual(cm.exception.smtp_error, + b'Requested action not taken: mailbox unavailable') + + def test_missing_subaddress(self): + # Trying to send a message to a bogus subaddress is an error. + with self.assertRaises(smtplib.SMTPDataError) as cm: + self._lmtp.sendmail('anne@example.com', + ['test-bogus@example.com'], """\ +From: anne.person@example.com +To: test-bogus@example.com +Subject: An interesting message +Message-ID: <aardvark> + +""") + self.assertEqual(cm.exception.smtp_code, 550) + self.assertEqual(cm.exception.smtp_error, + b'Requested action not taken: mailbox unavailable') + class TestBugs(unittest.TestCase): |
