From 186e5c3a7b05b6796d020a2fd861f8c7e61a0a01 Mon Sep 17 00:00:00 2001 From: jomae Date: Thu, 3 Oct 2024 08:52:16 +0000 Subject: [PATCH] 1.6.1dev: fix incorrect `Reply-To: <>` header generated in notification mail when `smtp_replyto` not configured (closes #13770) git-svn-id: http://trac.edgewall.org/intertrac/log:/branches/1.6-stable@17848 af82e41b-90c4-0310-8c96-b1721e28e2e2 --- trac/notification/mail.py | 3 ++- trac/notification/tests/mail.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/trac/notification/mail.py b/trac/notification/mail.py index 4c008f3deb..95a2768391 100644 --- a/trac/notification/mail.py +++ b/trac/notification/mail.py @@ -646,7 +646,8 @@ def _do_send(self, transport, event, message, cc_addrs, bcc_addrs): set_header(message, 'Cc', addresses=cc_addrs) if bcc_addrs: set_header(message, 'Bcc', addresses=bcc_addrs) - set_header(message, 'Reply-To', addresses=[smtp_replyto]) + if smtp_replyto: + set_header(message, 'Reply-To', addresses=[smtp_replyto]) for decorator in self.decorators: decorator.decorate_message(event, message, self._charset) diff --git a/trac/notification/tests/mail.py b/trac/notification/tests/mail.py index 23e8a6289c..7569605a76 100644 --- a/trac/notification/tests/mail.py +++ b/trac/notification/tests/mail.py @@ -509,6 +509,22 @@ def test_username_is_email(self): self._assert_equal_sets(['cc@example.org'], self._cclist(message['Cc'])) + def test_replyto(self): + config = self.env.config + config.set('notification', 'smtp_replyto', 'replyto@example.org') + self._notify_event('blah') + history = self.sender.history + from_addr, recipients, message = history[0] + self.assertEqual('replyto@example.org', message['Reply-To']) + + def test_replyto_empty(self): + config = self.env.config + config.set('notification', 'smtp_replyto', '') + self._notify_event('blah') + history = self.sender.history + from_addr, recipients, message = history[0] + self.assertNotIn('Reply-To', message) + class RecipientMatcherTestCase(unittest.TestCase):