From 72117dd5d3ab99ce7dd7751c8f6be9577e67291b Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 28 Apr 2017 12:56:32 +0530 Subject: [PATCH] [fix] email fixes from failed scheduler logs --- frappe/email/doctype/email_account/email_account.py | 2 +- frappe/email/receive.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frappe/email/doctype/email_account/email_account.py b/frappe/email/doctype/email_account/email_account.py index acf72cdea2..8f56f2a435 100755 --- a/frappe/email/doctype/email_account/email_account.py +++ b/frappe/email/doctype/email_account/email_account.py @@ -483,7 +483,7 @@ class EmailAccount(Document): parent = frappe.new_doc(self.append_to) if self.subject_field: - parent.set(self.subject_field, frappe.as_unicode(email.subject)) + parent.set(self.subject_field, frappe.as_unicode(email.subject)[:140]) if self.sender_field: parent.set(self.sender_field, frappe.as_unicode(email.from_email)) diff --git a/frappe/email/receive.py b/frappe/email/receive.py index d64eecdf9a..750ad865a9 100644 --- a/frappe/email/receive.py +++ b/frappe/email/receive.py @@ -112,6 +112,10 @@ class EmailServer: self.uid_reindexed = False uid_list = email_list = self.get_new_mails() + + if not email_list: + return + num = num_copy = len(email_list) # WARNING: Hard coded max no. of messages to be popped @@ -166,11 +170,13 @@ class EmailServer: def get_new_mails(self): """Return list of new mails""" if cint(self.settings.use_imap): + email_list = [] self.check_imap_uidvalidity() self.imap.select("Inbox", readonly=True) response, message = self.imap.uid('search', None, self.settings.email_sync_rule) - email_list = message[0].split() + if message[0]: + email_list = message[0].split() else: email_list = self.pop.list()[1]