fix: email address not displayed on the mask

This commit is contained in:
Zichao Lin 2024-07-24 00:24:10 +08:00
parent d6fc0a6d20
commit 9147206d0f
Signed by: earthjasonlin
GPG Key ID: 406D9913DE2E42FB
2 changed files with 7 additions and 3 deletions

@ -4,6 +4,7 @@ import smtplib
import email
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import parseaddr
import time
import logging
import socks
@ -20,7 +21,10 @@ def decode_mime_words(s):
def add_mask(original_msg, content):
original_subject = decode_mime_words(original_msg['Subject'])
header = f"""<table align=center style="background:#3d3d3d;padding:8px 16px;margin-top:30px;margin-bottom:30px;width:96%;border-radius:6px;max-width:1200px"width=100% bgcolor=#3D3D3D id=relay-email-header><tr><td style=font-size:xx-large;font-weight:bolder;color:#fff width=50% align=left>Forwarded Email<td style=color:#fff;text-align:right width=50% align=right><p>From: {original_msg['From']}<p>To: {original_msg['To']}<p>Subject: {original_subject}</table><table align=center style=padding:0;max-width:850px width=100%><tr><td style=padding-left:15px;padding-right:15px width=100%>"""
from_name, from_address = parseaddr(original_msg['From'])
to_name, to_address = parseaddr(original_msg['To'])
print(original_msg)
header = f"""<table align=center style="background:#3d3d3d;padding:8px 16px;margin-top:30px;margin-bottom:30px;width:96%;border-radius:6px;max-width:1200px"width=100% bgcolor=#3D3D3D id=relay-email-header><tr><td style=font-size:xx-large;font-weight:bolder;color:#fff width=50% align=left>Forwarded Email<td style=color:#fff;text-align:right width=50% align=right><p>From: {from_name} >{from_address}&lt;<p>To: {to_name} >{to_address}&lt;<p>Subject: {original_subject}</table><table align=center style=padding:0;max-width:850px width=100%><tr><td style=padding-left:15px;padding-right:15px width=100%>"""
footer = f"""<table align=center bgcolor=#3D3D3D style="background:#3d3d3d;padding:8px 16px;margin-top:30px;margin-bottom:30px;width:96%;border-radius:6px;max-width:1200px"width=100%><tr><td align=left style=color:#d22;font-size:xx-large;font-weight:bolder width=50%>FORWARDED<td align=right style=color:#fff;text-align:left width=50%><p style=font-size:x-large;font-weight:700;margin-block:0>Notice:<p style=margin-block:.1em>This is a automatically forwarded email, which means it may contains something bad.<p style=margin-block:.1em>You shouldn't reply directly to this email, it will never reach your destination!</table>"""
return header + content + footer

@ -25,8 +25,8 @@
Forwarded Email
</td>
<td width="50%" align="right" style="color: #ffffff; text-align: right;">
<p>From: {original_msg['From']}</p>
<p>To: {original_msg['To']}</p>
<p>From: {from_name} &gt;{from_address}&lt;</p>
<p>To: {to_name} &gt;{to_address}&lt;</p>
<p>Subject: {original_subject}</p>
</td>
</tr>