From fe52ac7203859f2a536fdf901ee0b5cc2afef9fe Mon Sep 17 00:00:00 2001 From: Ruud Date: Wed, 16 Jan 2013 19:45:39 +0100 Subject: [PATCH] Use default title as email subject --- couchpotato/core/notifications/email/__init__.py | 5 ----- couchpotato/core/notifications/email/main.py | 22 +++++++++------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/couchpotato/core/notifications/email/__init__.py b/couchpotato/core/notifications/email/__init__.py index c260135..ed55528 100644 --- a/couchpotato/core/notifications/email/__init__.py +++ b/couchpotato/core/notifications/email/__init__.py @@ -24,11 +24,6 @@ config = [{ 'label': 'Send e-mail to', }, { - 'name': 'subject', - 'label': 'Subject', - 'default': 'Couch Potato report', - }, - { 'name': 'smtp_server', 'label': 'SMTP server', }, diff --git a/couchpotato/core/notifications/email/main.py b/couchpotato/core/notifications/email/main.py index 492462d..118ed1b 100644 --- a/couchpotato/core/notifications/email/main.py +++ b/couchpotato/core/notifications/email/main.py @@ -2,8 +2,8 @@ from couchpotato.core.helpers.encoding import toUnicode from couchpotato.core.logger import CPLog from couchpotato.core.notifications.base import Notification from email.mime.text import MIMEText -import traceback import smtplib +import traceback log = CPLog(__name__) @@ -13,35 +13,31 @@ class Email(Notification): def notify(self, message = '', data = {}, listener = None): if self.isDisabled(): return - # Extract all the settings from the database + # Extract all the settings from settings from_address = self.conf('from') to = self.conf('to') smtp_server = self.conf('smtp_server') ssl = self.conf('ssl') smtp_user = self.conf('smtp_user') smtp_pass = self.conf('smtp_pass') - + # Make the basic message message = MIMEText(toUnicode(message)) - message['Subject'] = self.conf('subject') + message['Subject'] = self.default_title message['From'] = from_address message['To'] = to - + try: # Open the SMTP connection, via SSL if requested - if ssl == 1: - mailserver = smtplib.SMTP_SSL(smtp_server) - else: - mailserver = smtplib.SMTP(smtp_server) + mailserver = smtplib.SMTP_SSL(smtp_server) if ssl == 1 else smtplib.SMTP(smtp_server) - # Check too see if an login attempt should be attempted if len(smtp_user) > 0: mailserver.login(smtp_user, smtp_pass) - + # Send the e-mail mailserver.sendmail(from_address, to, message.as_string()) - + # Close the SMTP connection mailserver.quit() log.info('Email notifications sent.') @@ -49,5 +45,5 @@ class Email(Notification): except: log.error('E-mail failed: %s', traceback.format_exc()) return False - + return False