From 3af5d98c0c077737a3fc1137e16c175b37a4dc71 Mon Sep 17 00:00:00 2001 From: trevor Date: Fri, 13 Jan 2023 22:10:23 -0800 Subject: [PATCH] Adds optional reply-to email reporter config param --- lib/urlwatch/mailer.py | 6 ++++-- lib/urlwatch/reporters.py | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/urlwatch/mailer.py b/lib/urlwatch/mailer.py index 2332beb0..06bf9285 100644 --- a/lib/urlwatch/mailer.py +++ b/lib/urlwatch/mailer.py @@ -49,21 +49,23 @@ class Mailer(object): def send(self, msg): raise NotImplementedError - def msg_plain(self, from_email, to_email, subject, body): + def msg_plain(self, from_email, to_email, reply_to_email, subject, body): msg = email.mime.text.MIMEText(body, 'plain', 'utf-8') msg['Subject'] = subject msg['From'] = from_email msg['To'] = to_email msg['Date'] = email.utils.formatdate() + msg['Reply-To'] = reply_to_email return msg - def msg_html(self, from_email, to_email, subject, body_text, body_html): + def msg_html(self, from_email, to_email, reply_to_email, subject, body_text, body_html): msg = email.mime.multipart.MIMEMultipart('alternative') msg['Subject'] = subject msg['From'] = from_email msg['To'] = to_email msg['Date'] = email.utils.formatdate() + msg['Reply-To'] = reply_to_email msg.attach(email.mime.text.MIMEText(body_text, 'plain', 'utf-8')) msg.attach(email.mime.text.MIMEText(body_html, 'html', 'utf-8')) diff --git a/lib/urlwatch/reporters.py b/lib/urlwatch/reporters.py index e3983417..1e18ff35 100644 --- a/lib/urlwatch/reporters.py +++ b/lib/urlwatch/reporters.py @@ -455,12 +455,13 @@ def submit(self): else: logger.error('Invalid entry for method {method}'.format(method=self.config['method'])) + reply_to = self.config.get('reply_to', self.config['from']) if self.config['html']: body_html = '\n'.join(self.convert(HtmlReporter).submit()) - msg = mailer.msg_html(self.config['from'], self.config['to'], subject, body_text, body_html) + msg = mailer.msg_html(self.config['from'], self.config['to'], reply_to, subject, body_text, body_html) else: - msg = mailer.msg_plain(self.config['from'], self.config['to'], subject, body_text) + msg = mailer.msg_plain(self.config['from'], self.config['to'], reply_to, subject, body_text) mailer.send(msg)