Website contact form endpoint

This commit is contained in:
2026-06-21 17:45:31 -04:00
parent a3f1a10bf5
commit 05e7859447
6 changed files with 232 additions and 3 deletions
+11 -2
View File
@@ -19,7 +19,14 @@ class EmailService:
template_dir = os.path.join(os.path.dirname(__file__), '..', 'templates')
self.jinja_env = Environment(loader=FileSystemLoader(template_dir))
async def send_email(self, to_email: str, subject: str, template_name: str, template_vars: dict):
async def send_email(
self,
to_email: str,
subject: str,
template_name: str,
template_vars: dict,
reply_to: str | None = None,
):
# Render the template
template = self.jinja_env.get_template(template_name)
html_content = template.render(**template_vars)
@@ -29,6 +36,8 @@ class EmailService:
msg['Subject'] = subject
msg['From'] = f"{self.from_name} <{self.from_email}>"
msg['To'] = to_email
if reply_to:
msg['Reply-To'] = reply_to
# Attach HTML content
html_part = MIMEText(html_content, 'html')
@@ -45,4 +54,4 @@ class EmailService:
# In production, use logging
email_service = EmailService()
email_service = EmailService()