mirror of
https://github.com/akissinger/dodo.git
synced 2024-10-04 06:27:25 +03:00
Merge pull request #47 from laarmen/multiline-header
compose: directly load the draft into the final EmailMessage object
This commit is contained in:
commit
add030278c
@ -27,10 +27,12 @@ import email
|
||||
import email.utils
|
||||
import email.parser
|
||||
import email.policy
|
||||
import email.message
|
||||
import mimetypes
|
||||
import subprocess
|
||||
from subprocess import PIPE, Popen, TimeoutExpired
|
||||
import tempfile
|
||||
import typing
|
||||
import os
|
||||
import re
|
||||
|
||||
@ -411,20 +413,15 @@ class SendmailThread(QThread):
|
||||
def run(self) -> None:
|
||||
try:
|
||||
account = self.panel.account_name()
|
||||
m = email.message_from_string(self.panel.message_string)
|
||||
eml = email.message.EmailMessage(policy=email.policy.EmailPolicy(utf8=False))
|
||||
attachments: List[str] = m.get_all('A', [])
|
||||
|
||||
# n.b. this kills duplicate headers. May want to revisit this if it causes problems.
|
||||
for h in m.keys():
|
||||
if h != 'A':
|
||||
eml[h] = m[h]
|
||||
eml = typing.cast(email.message.EmailMessage, email.message_from_string(
|
||||
self.panel.message_string,
|
||||
policy = email.policy.EmailPolicy(utf8=False)))
|
||||
attachments: List[str] = eml.get_all('A', [])
|
||||
del eml['A']
|
||||
|
||||
eml['Message-ID'] = email.utils.make_msgid()
|
||||
eml['User-Agent'] = 'Dodo'
|
||||
|
||||
eml.set_content(m.get_payload())
|
||||
|
||||
# add a date if it's missing
|
||||
if not "Date" in eml:
|
||||
eml["Date"] = email.utils.formatdate(localtime=True)
|
||||
|
Loading…
Reference in New Issue
Block a user