From afdfb30d80e0f8524f61d0f8cb62b4e62496318b Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Wed, 18 Jan 2017 19:07:45 +0100 Subject: [PATCH] Update email settings --- cps/db.py | 2 +- cps/helper.py | 26 ++++++++++++-------------- cps/templates/email_edit.html | 10 +++++++--- cps/web.py | 5 +---- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/cps/db.py b/cps/db.py index 1ca1c8cb..ac6e7900 100755 --- a/cps/db.py +++ b/cps/db.py @@ -105,7 +105,7 @@ class Identifiers(Base): if self.type == "amazon": return u"https://amzn.com/{0}".format(self.val) elif self.type == "isbn": - return u"http://http://www.worldcat.org/isbn/{0}".format(self.val) + return u"http://www.worldcat.org/isbn/{0}".format(self.val) elif self.type == "doi": return u"http://dx.doi.org/{0}".format(self.val) elif self.type == "goodreads": diff --git a/cps/helper.py b/cps/helper.py index 58722ac7..0e0bc934 100755 --- a/cps/helper.py +++ b/cps/helper.py @@ -113,16 +113,16 @@ def send_test_mail(kindle_mail): org_stderr = smtplib.stderr smtplib.stderr = StderrLogger() - if int(use_ssl) == 1: + if int(use_ssl) == 2: mailserver = smtplib.SMTP_SSL(settings["mail_server"], settings["mail_port"], timeout) else: mailserver = smtplib.SMTP(settings["mail_server"], settings["mail_port"], timeout) mailserver.set_debuglevel(1) - # if int(use_ssl) == 1: - # mailserver.ehlo() - # mailserver.starttls() - # mailserver.ehlo() + if int(use_ssl) == 1: + #mailserver.ehlo() + mailserver.starttls() + #mailserver.ehlo() if settings["mail_password"]: mailserver.login(settings["mail_login"], settings["mail_password"]) @@ -151,8 +151,8 @@ def send_mail(book_id, kindle_mail): msg = MIMEMultipart() msg['From'] = settings["mail_from"] msg['To'] = kindle_mail - msg['Subject'] = _('Send to Kindle') - text = _('This email has been sent via calibre web.') + msg['Subject'] = _(u'Send to Kindle') + text = _(u'This email has been sent via calibre web.') msg.attach(MIMEText(text.encode('UTF-8'), 'plain', 'UTF-8')) use_ssl = settings.get('mail_use_ssl', 0) @@ -204,16 +204,14 @@ def send_mail(book_id, kindle_mail): org_stderr = smtplib.stderr smtplib.stderr = StderrLogger() - if int(use_ssl) == 1: - mailserver = smtplib.SMTP_SSL(settings["mail_server"], settings["mail_port"],timeout) + if int(use_ssl) == 2: + mailserver = smtplib.SMTP_SSL(settings["mail_server"], settings["mail_port"], timeout) else: - mailserver = smtplib.SMTP(settings["mail_server"], settings["mail_port"],timeout) + mailserver = smtplib.SMTP(settings["mail_server"], settings["mail_port"], timeout) mailserver.set_debuglevel(1) - # if int(use_ssl) == 1: - # mailserver.ehlo() - # mailserver.starttls() - # mailserver.ehlo() + if int(use_ssl) == 1: + mailserver.starttls() if settings["mail_password"]: mailserver.login(settings["mail_login"], settings["mail_password"]) diff --git a/cps/templates/email_edit.html b/cps/templates/email_edit.html index 5ff57e99..42596a9a 100644 --- a/cps/templates/email_edit.html +++ b/cps/templates/email_edit.html @@ -8,12 +8,16 @@
- +
- - + +
diff --git a/cps/web.py b/cps/web.py index 584ffcb1..53b529fb 100755 --- a/cps/web.py +++ b/cps/web.py @@ -1562,10 +1562,7 @@ def edit_mailsettings(): content.mail_login = to_save["mail_login"] content.mail_password = to_save["mail_password"] content.mail_from = to_save["mail_from"] - if "mail_use_ssl" in to_save: - content.mail_use_ssl = 1 - else: - content.mail_use_ssl = 0 + content.mail_use_ssl = int(to_save["mail_use_ssl"]) try: ub.session.commit() flash(_(u"Mail settings updated"), category="success")