Files
wiki-tcg/backend/email_utils.py
2026-03-19 22:34:02 +01:00

27 lines
1.1 KiB
Python

import resend
import os
from config import RESEND_API_KEY, EMAIL_FROM, FRONTEND_URL
def send_password_reset_email(to_email: str, username: str, reset_token: str):
resend.api_key = RESEND_API_KEY
reset_url = f"{FRONTEND_URL}/forgot-password/reset?token={reset_token}"
resend.Emails.send({
"from": EMAIL_FROM,
"to": to_email,
"subject": "Reset your WikiTCG password",
"html": f"""
<div style="font-family: serif; max-width: 480px; margin: 0 auto; color: #1a1208;">
<h2 style="color: #b87830;">WikiTCG Password Reset</h2>
<p>Hi {username},</p>
<p>Someone requested a password reset for your account. If this was you, click the link below:</p>
<p style="margin: 2rem 0;">
<a href="{reset_url}" style="background: #c8861a; color: #fff8e0; padding: 10px 24px; border-radius: 6px; text-decoration: none; font-family: sans-serif; font-size: 14px;">
Reset Password
</a>
</p>
<p>This link expires in 1 hour. If you didn't request this, you can safely ignore this email.</p>
<p style="color: #888; font-size: 13px;">- WikiTCG</p>
</div>
""",
})