fix exception

This commit is contained in:
Cyberes 2024-03-06 10:28:27 -07:00
parent 5870303c74
commit 0b0779fca0
1 changed files with 15 additions and 4 deletions

View File

@ -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: