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:
+2
-1
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user