diff options
Diffstat (limited to 'src/mailman/mta')
| -rw-r--r-- | src/mailman/mta/connection.py | 5 | ||||
| -rw-r--r-- | src/mailman/mta/docs/connection.txt | 41 |
2 files changed, 46 insertions, 0 deletions
diff --git a/src/mailman/mta/connection.py b/src/mailman/mta/connection.py index 105d25afb..36af7a06e 100644 --- a/src/mailman/mta/connection.py +++ b/src/mailman/mta/connection.py @@ -28,6 +28,7 @@ __all__ = [ import logging import smtplib +from lazr.config import as_boolean from mailman.config import config @@ -66,6 +67,10 @@ class Connection: def sendmail(self, envsender, recips, msgtext): """Mimic `smtplib.SMTP.sendmail`.""" + if as_boolean(config.mailman.devmode): + # Force the recipients to the specified address, but still deliver + # to the same number of recipients. + recips = [config.mta.devmode_recipient] * len(recips) if self._connection is None: self._connect() try: diff --git a/src/mailman/mta/docs/connection.txt b/src/mailman/mta/docs/connection.txt index 8924826c8..c79120eba 100644 --- a/src/mailman/mta/docs/connection.txt +++ b/src/mailman/mta/docs/connection.txt @@ -155,3 +155,44 @@ the server. >>> smtpd.get_connection_count() 1 + + +Development mode +================ + +By putting Mailman into development mode, you can force the recipients to a +given hard-coded address. This allows you to test Mailman without worrying +about accidental deliveries to unintended recipients. + + >>> config.push('devmode', """ + ... [mailman] + ... devmode: true + ... [mta] + ... devmode_recipient: zperson@example.com + ... """) + + >>> smtpd.clear() + >>> connection.sendmail( + ... 'anne@example.com', + ... ['bart@example.com', 'cate@example.com'], """\ + ... From: anne@example.com + ... To: bart@example.com + ... Subject: aardvarks + ... + ... """) + {} + + >>> messages = list(smtpd.messages) + >>> len(messages) + 1 + >>> print messages[0].as_string() + From: anne@example.com + To: bart@example.com + Subject: aardvarks + X-Peer: ... + X-MailFrom: anne@example.com + X-RcptTo: zperson@example.com, zperson@example.com + <BLANKLINE> + <BLANKLINE> + + >>> config.pop('devmode') |
