Pārlūkot izejas kodu

Fix embedded image cid for named senders with a 'from' address like 'WhateverSender <noreply@sender.com>'

Stefan Vietze 4 gadi atpakaļ
vecāks
revīzija
0449b6d7e6
1 mainītis faili ar 3 papildinājumiem un 3 dzēšanām
  1. 3 3
      redmail/email/body.py

+ 3 - 3
redmail/email/body.py

@@ -9,7 +9,7 @@ from pathlib import Path
 from redmail.utils import is_bytes
 from redmail.utils import import_from_string
 
-from email.utils import make_msgid
+from email.utils import make_msgid, parseaddr
 
 from jinja2.environment import Template, Environment
 
@@ -109,7 +109,7 @@ class HTMLBody(Body):
             jinja_params : dict
                 Extra Jinja parameters for the HTML.
         """
-        domain = msg["from"].split("@")[-1] if self.domain is None else self.domain
+        domain = parseaddr(msg["from"])[1].split("@")[-1] if self.domain is None else self.domain
         html, cids = self.render(
             html, 
             images=images,
@@ -244,4 +244,4 @@ class HTMLBody(Body):
                 img_content,
                 cid=cid,
                 **kwds
-            )
+            )