mirror of
https://github.com/simple-login/app.git
synced 2024-09-20 15:05:59 +08:00
use full email header in replace_header_when_reply
This commit is contained in:
parent
f78e790b71
commit
18844b7011
|
@ -37,7 +37,7 @@ from email import encoders
|
||||||
from email.message import Message
|
from email.message import Message
|
||||||
from email.mime.application import MIMEApplication
|
from email.mime.application import MIMEApplication
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
from email.utils import parseaddr
|
from email.utils import parseaddr, formataddr
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from smtplib import SMTP
|
from smtplib import SMTP
|
||||||
|
|
||||||
|
@ -211,22 +211,21 @@ def replace_header_when_reply(msg: Message, alias: Alias, header: str):
|
||||||
new_addrs: [str] = []
|
new_addrs: [str] = []
|
||||||
|
|
||||||
for addr in addrs:
|
for addr in addrs:
|
||||||
name, email = parseaddr(addr)
|
name, reply_email = parseaddr(addr)
|
||||||
|
|
||||||
# no transformation when alias is already in the header
|
# no transformation when alias is already in the header
|
||||||
if email == alias.email:
|
if reply_email == alias.email:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
contact = Contact.get_by(reply_email=email)
|
contact = Contact.get_by(reply_email=reply_email)
|
||||||
if not contact:
|
if not contact:
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"%s email in reply phase %s must be reply emails", header, email
|
"%s email in reply phase %s must be reply emails", header, reply_email
|
||||||
)
|
)
|
||||||
# still keep this email in header
|
# still keep this email in header
|
||||||
new_addrs.append(addr)
|
new_addrs.append(addr)
|
||||||
continue
|
else:
|
||||||
|
new_addrs.append(formataddr((contact.name, contact.website_email)))
|
||||||
new_addrs.append(contact.website_from or contact.website_email)
|
|
||||||
|
|
||||||
new_header = ",".join(new_addrs)
|
new_header = ",".join(new_addrs)
|
||||||
LOG.d("Replace %s header, old: %s, new: %s", header, msg[header], new_header)
|
LOG.d("Replace %s header, old: %s, new: %s", header, msg[header], new_header)
|
||||||
|
|
Loading…
Reference in a new issue