mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-31 12:00:08 -07:00
Add plaintext message to newsletter email
This commit is contained in:
parent
c5918d7d6c
commit
445eea5c1e
2 changed files with 19 additions and 5 deletions
|
@ -470,18 +470,24 @@ class Newsletter(object):
|
||||||
if self.config['formatted']:
|
if self.config['formatted']:
|
||||||
newsletter_stripped = ''.join(l.strip() for l in self.newsletter.splitlines())
|
newsletter_stripped = ''.join(l.strip() for l in self.newsletter.splitlines())
|
||||||
|
|
||||||
|
plaintext = 'HTML email support is required to view the newsletter.\n'
|
||||||
|
if plexpy.CONFIG.NEWSLETTER_SELF_HOSTED and plexpy.CONFIG.HTTP_BASE_URL:
|
||||||
|
plaintext += self._DEFAULT_BODY.format(**self.parameters)
|
||||||
|
|
||||||
if self.email_config['notifier_id']:
|
if self.email_config['notifier_id']:
|
||||||
return send_notification(
|
return send_notification(
|
||||||
notifier_id=self.email_config['notifier_id'],
|
notifier_id=self.email_config['notifier_id'],
|
||||||
subject=self.subject_formatted,
|
subject=self.subject_formatted,
|
||||||
body=newsletter_stripped
|
body=newsletter_stripped,
|
||||||
|
plaintext=plaintext
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
email = EMAIL(config=self.email_config)
|
email = EMAIL(config=self.email_config)
|
||||||
return email.notify(
|
return email.notify(
|
||||||
subject=self.subject_formatted,
|
subject=self.subject_formatted,
|
||||||
body=newsletter_stripped
|
body=newsletter_stripped,
|
||||||
|
plaintext=plaintext
|
||||||
)
|
)
|
||||||
elif self.config['notifier_id']:
|
elif self.config['notifier_id']:
|
||||||
return send_notification(
|
return send_notification(
|
||||||
|
|
|
@ -1295,11 +1295,19 @@ class EMAIL(Notifier):
|
||||||
|
|
||||||
def agent_notify(self, subject='', body='', action='', **kwargs):
|
def agent_notify(self, subject='', body='', action='', **kwargs):
|
||||||
if self.config['html_support']:
|
if self.config['html_support']:
|
||||||
|
plain = MIMEText(None, 'plain', 'utf-8')
|
||||||
|
plain.replace_header('Content-Transfer-Encoding', 'quoted-printable')
|
||||||
|
plain.set_payload(kwargs.get('plaintext', bleach.clean(body, strip=True)), 'utf-8')
|
||||||
|
|
||||||
|
html = MIMEText(body, 'html', 'utf-8')
|
||||||
|
|
||||||
msg = MIMEMultipart('alternative')
|
msg = MIMEMultipart('alternative')
|
||||||
msg.attach(MIMEText(bleach.clean(body, strip=True), 'plain', 'utf-8'))
|
msg.attach(plain)
|
||||||
msg.attach(MIMEText(body, 'html', 'utf-8'))
|
msg.attach(html)
|
||||||
else:
|
else:
|
||||||
msg = MIMEText(body, 'plain', 'utf-8')
|
msg = MIMEText(None, 'plain', 'utf-8')
|
||||||
|
msg.replace_header('Content-Transfer-Encoding', 'quoted-printable')
|
||||||
|
msg.set_payload(body, 'utf-8')
|
||||||
|
|
||||||
msg['Message-ID'] = email.utils.make_msgid()
|
msg['Message-ID'] = email.utils.make_msgid()
|
||||||
msg['Date'] = email.utils.formatdate(localtime=True)
|
msg['Date'] = email.utils.formatdate(localtime=True)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue