Skip to content

Commit

Permalink
docs: send a confirmation email from contact form
Browse files Browse the repository at this point in the history
  • Loading branch information
iisakkirotko committed Oct 11, 2024
1 parent 2b58290 commit 6b224c8
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion solara/website/components/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def send(*_ignore):
<b>Message</b>: {message.value}<br />
"""

# Send the email
# Send emails
try:
requests.post(
"https://api.postmarkapp.com/email",
Expand All @@ -65,6 +65,26 @@ def send(*_ignore):
},
data=json.dumps(msg),
)
requests.post(
"https://api.postmarkapp.com/email",
headers={
"Accept": "application/json",
"Content-Type": "application/json",
"X-Postmark-Server-Token": postmark_api_key,
},
data=json.dumps(
{
"From": contact_email_address,
"To": email.value,
"Subject": "Thank you for contacting Solara",
"HtmlBody": f"""
<p>Hi {first_name.value},</p>
<p>Thank you for contacting us! We will get back to you as soon as possible.</p>
<p>Best regards,<br />The Solara Team</p>
""",
}
),
)
print("Email sent successfully!")
except Exception as e:
error.set(f"Error sending email: {e}")
Expand Down

0 comments on commit 6b224c8

Please sign in to comment.