fix: кнопка на главную после оплаты + исправление отправки SMTP письма

This commit is contained in:
2026-06-21 13:34:37 +03:00
parent dc49bef644
commit c2aa9b6442
3 changed files with 17 additions and 27 deletions
+10 -4
View File
@@ -452,11 +452,12 @@ def send_email_notification(reg_id, data, paid=False):
</html>
"""
server = None
try:
msg = MIMEMultipart('alternative')
msg['Subject'] = subject
msg['From'] = smtp_from
msg['To'] = smtp_to
msg['To'] = ', '.join(smtp_to) # заголовок — строка
msg.attach(MIMEText(html_content, 'html', 'utf-8'))
if smtp_port == 465:
@@ -464,15 +465,20 @@ def send_email_notification(reg_id, data, paid=False):
else:
server = smtplib.SMTP(smtp_server, smtp_port)
server.starttls()
server.login(smtp_user, smtp_password)
server.sendmail(smtp_from, [smtp_to], msg.as_string())
server.quit()
server.sendmail(smtp_from, smtp_to, msg.as_string()) # smtp_to — список
print(f"[SMTP] Письмо о заказе {reg_id} отправлено на {smtp_to}")
return True
except Exception as e:
print(f"[SMTP] Ошибка отправки письма: {e}")
return False
finally:
if server:
try:
server.quit()
except Exception:
pass
# ====================================================
# Flask Web App Routes