fix: Mail.ru SMTP — кодировка кириллицы в From header

Mail.ru отклоняет raw кириллицу в headers (550 invalid headers).
Используем email.header.Header для RFC 2047 encoding.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
anor
2026-03-27 16:07:29 +10:00
co-authored by Claude Opus 4.6
parent 0469dd85e7
commit ee3d3e8c24
+2 -1
View File
@@ -36,7 +36,8 @@ def send_verification_code(to_email: str, code: str) -> bool:
msg = MIMEMultipart("alternative")
msg["Subject"] = subject
msg["From"] = f"Сметный ассистент <{SMTP_USER}>"
from email.header import Header
msg["From"] = f"{Header('Сметный ассистент', 'utf-8').encode()} <{SMTP_USER}>"
msg["To"] = to_email
msg.attach(MIMEText(f"Ваш код подтверждения: {code}\nДействителен 10 минут.", "plain", "utf-8"))
msg.attach(MIMEText(html, "html", "utf-8"))