diff options
| author | Barry Warsaw | 2017-08-04 01:13:04 +0000 |
|---|---|---|
| committer | Barry Warsaw | 2017-08-04 01:13:04 +0000 |
| commit | 9cdcffbc1189a19bc2963cf3d5c86a3d4f1f24a6 (patch) | |
| tree | f021166b8c82bb02feff82a9360ba61a44b804ee /src/mailman/app/bounces.py | |
| parent | e6326533b78290514ede917ed1cb95804759a45a (diff) | |
| download | mailman-9cdcffbc1189a19bc2963cf3d5c86a3d4f1f24a6.tar.gz mailman-9cdcffbc1189a19bc2963cf3d5c86a3d4f1f24a6.tar.zst mailman-9cdcffbc1189a19bc2963cf3d5c86a3d4f1f24a6.zip | |
Diffstat (limited to 'src/mailman/app/bounces.py')
| -rw-r--r-- | src/mailman/app/bounces.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mailman/app/bounces.py b/src/mailman/app/bounces.py index 1239c916c..0d9a6ccb9 100644 --- a/src/mailman/app/bounces.py +++ b/src/mailman/app/bounces.py @@ -45,6 +45,7 @@ elog = logging.getLogger('mailman.error') blog = logging.getLogger('mailman.bounce') DOT = '.' +NL = '\n' @public @@ -56,8 +57,12 @@ def bounce_message(mlist, msg, error=None): :param msg: The original message. :type msg: `email.message.Message` :param error: Optional exception causing the bounce. The exception - instance must have a `.message` attribute. - :type error: Exception + instance must have a `.message` attribute. The exception *may* have a + non-None `.reasons` attribute which would be a list of reasons for the + rejection, and it may have a non-None `.substitutions` attribute. The + latter, along with the formatted reasons will be interpolated into the + message (`.reasons` gets put into the `$reasons` placeholder). + :type error: RejectMessage """ # Bounce a message back to the sender, with an error message if provided # in the exception argument. .sender might be None or the empty string. @@ -67,10 +72,9 @@ def bounce_message(mlist, msg, error=None): return subject = msg.get('subject', _('(no subject)')) subject = oneline(subject, mlist.preferred_language.charset) - if error is None: - notice = _('[No bounce details are available]') - else: - notice = _(error.message) + notice = (_('[No bounce details are available]') + if error is None + else str(error)) # Currently we always craft bounces as MIME messages. bmsg = UserNotification(msg.sender, mlist.owner_address, subject, lang=mlist.preferred_language) |
