|
|
|
@ -29,6 +29,7 @@ import re
|
|
|
|
|
import time |
|
|
|
|
import getpass |
|
|
|
|
import socket |
|
|
|
|
import mimetypes |
|
|
|
|
from pathlib import Path |
|
|
|
|
|
|
|
|
|
from messaging.mms.message import MMSMessage |
|
|
|
@ -183,20 +184,24 @@ class MMS2Mail:
|
|
|
|
|
message.headers.append((f"X-MMS-{header}", |
|
|
|
|
f"{mms.headers[header]}")) |
|
|
|
|
|
|
|
|
|
message.plain = " " |
|
|
|
|
data_id = 1 |
|
|
|
|
for data_part in mms.data_parts: |
|
|
|
|
datacontent = data_part.headers['Content-Type'] |
|
|
|
|
if datacontent is not None: |
|
|
|
|
if 'text/plain' in datacontent[0]: |
|
|
|
|
message.plain = f"{data_part.data} \n" |
|
|
|
|
if 'Name' in datacontent[1]: |
|
|
|
|
filename = datacontent[1]['Name'] |
|
|
|
|
message.attach(filename, data_part.data) |
|
|
|
|
# Ensure a proper body content in the resulting mail |
|
|
|
|
if not message.plain: |
|
|
|
|
message.plain = " " |
|
|
|
|
encoding = datacontent[1].get('Charset', 'utf-8') |
|
|
|
|
plain = data_part.data.decode(encoding) |
|
|
|
|
message.plain += plain + '\n' |
|
|
|
|
continue |
|
|
|
|
extension = mimetypes.guess_extension(datacontent[0]) |
|
|
|
|
filename = datacontent[1].get('Name', str(data_id)) |
|
|
|
|
message.attach(filename + extension, data_part.data) |
|
|
|
|
data_id = data_id + 1 |
|
|
|
|
|
|
|
|
|
# Add MMS binary file, for debugging purpose or reparsing in the future |
|
|
|
|
if self.attach_mms: |
|
|
|
|
message.attach(path, None, None, None, False, "mms.bin") |
|
|
|
|
message.attach(path, None, None, None, False, path.split('/')[-1]) |
|
|
|
|
|
|
|
|
|
# Creating an empty file stating the mms as been converted |
|
|
|
|
self.mark_mms_read(dbus_path) |
|
|
|
|