fix exception
This commit is contained in:
parent
5870303c74
commit
0b0779fca0
|
@ -44,7 +44,7 @@ class MailConnection:
|
|||
self.mail.login(username, password)
|
||||
self.attachments_dir = attachments_dir.expanduser().absolute().resolve()
|
||||
self.folder_structure = {}
|
||||
self.logger = logging.getLogger('iarchiver.mail')
|
||||
self.logger = logging.getLogger('iarchiver.mail_conn')
|
||||
self.logger.setLevel(logging.INFO)
|
||||
|
||||
def load_folders(self):
|
||||
|
@ -77,10 +77,21 @@ class MailConnection:
|
|||
date = parsedate_to_datetime(date_header)
|
||||
unix_timestamp = int(time.mktime(date.timetuple()))
|
||||
|
||||
from_header = ', '.join(extract_emails(email_message['From']))
|
||||
to_header = ', '.join(extract_emails(email_message['To']))
|
||||
from_addr = email_message['From']
|
||||
to_addr = email_message['To']
|
||||
if not from_addr and not to_addr:
|
||||
return
|
||||
if not from_addr:
|
||||
from_addr = ''
|
||||
if not to_addr:
|
||||
to_addr = ''
|
||||
|
||||
from_header = ', '.join(extract_emails(from_addr))
|
||||
to_header = ', '.join(extract_emails(to_addr))
|
||||
if '@' not in from_header:
|
||||
from_header = from_addr
|
||||
if '@' not in to_header:
|
||||
to_header = email_message['To']
|
||||
to_header = to_addr
|
||||
|
||||
subject_header = email_message['Subject']
|
||||
if subject_header:
|
||||
|
|
Loading…
Reference in New Issue