mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 04:49:36 -07:00
Fix Email HTML
This commit is contained in:
parent
d09c7b13b3
commit
6e5b02d326
2 changed files with 10 additions and 7 deletions
|
@ -86,6 +86,7 @@ _CONFIG_DEFINITIONS = {
|
||||||
'EMAIL_SMTP_PASSWORD': (str, 'Email', ''),
|
'EMAIL_SMTP_PASSWORD': (str, 'Email', ''),
|
||||||
'EMAIL_SMTP_PORT': (int, 'Email', 25),
|
'EMAIL_SMTP_PORT': (int, 'Email', 25),
|
||||||
'EMAIL_TLS': (int, 'Email', 0),
|
'EMAIL_TLS': (int, 'Email', 0),
|
||||||
|
'EMAIL_HTML_SUPPORT': (int, 'Email', 1),
|
||||||
'EMAIL_ON_PLAY': (int, 'Email', 0),
|
'EMAIL_ON_PLAY': (int, 'Email', 0),
|
||||||
'EMAIL_ON_STOP': (int, 'Email', 0),
|
'EMAIL_ON_STOP': (int, 'Email', 0),
|
||||||
'EMAIL_ON_PAUSE': (int, 'Email', 0),
|
'EMAIL_ON_PAUSE': (int, 'Email', 0),
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
import base64
|
import base64
|
||||||
|
import bleach
|
||||||
import json
|
import json
|
||||||
import cherrypy
|
import cherrypy
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
|
@ -1538,23 +1539,24 @@ class Email(object):
|
||||||
self.smtp_user = plexpy.CONFIG.EMAIL_SMTP_USER
|
self.smtp_user = plexpy.CONFIG.EMAIL_SMTP_USER
|
||||||
self.smtp_password = plexpy.CONFIG.EMAIL_SMTP_PASSWORD
|
self.smtp_password = plexpy.CONFIG.EMAIL_SMTP_PASSWORD
|
||||||
self.tls = plexpy.CONFIG.EMAIL_TLS
|
self.tls = plexpy.CONFIG.EMAIL_TLS
|
||||||
self.html_support = plexpy.CONFIG.TELEGRAM_HTML_SUPPORT
|
self.html_support = plexpy.CONFIG.EMAIL_HTML_SUPPORT
|
||||||
|
|
||||||
def notify(self, subject, message):
|
def notify(self, subject, message):
|
||||||
if not subject or not message:
|
if not subject or not message:
|
||||||
return
|
return
|
||||||
|
|
||||||
msg = MIMEMultipart('alternative')
|
if self.html_support:
|
||||||
|
msg = MIMEMultipart('alternative')
|
||||||
|
msg.attach(MIMEText(bleach.clean(message, strip=True), 'plain', 'utf-8'))
|
||||||
|
msg.attach(MIMEText(message, 'html', 'utf-8'))
|
||||||
|
else:
|
||||||
|
msg = MIMEText(message, 'plain', 'utf-8')
|
||||||
|
|
||||||
msg['Subject'] = subject
|
msg['Subject'] = subject
|
||||||
msg['From'] = email.utils.formataddr((self.from_name, self.email_from))
|
msg['From'] = email.utils.formataddr((self.from_name, self.email_from))
|
||||||
msg['To'] = self.email_to
|
msg['To'] = self.email_to
|
||||||
msg['CC'] = self.email_cc
|
msg['CC'] = self.email_cc
|
||||||
|
|
||||||
p = re.compile(r'<.*?>')
|
|
||||||
plain_message = p.sub('', message)
|
|
||||||
|
|
||||||
msg.attach(MIMEText(plain_message, 'plain'))
|
|
||||||
msg.attach(MIMEText(message, 'html'))
|
|
||||||
|
|
||||||
recipients = [x.strip() for x in self.email_to.split(';')] \
|
recipients = [x.strip() for x in self.email_to.split(';')] \
|
||||||
+ [x.strip() for x in self.email_cc.split(';')] \
|
+ [x.strip() for x in self.email_cc.split(';')] \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue