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):