From 132f2c987a96437b6f469beea725518c9b8c6031 Mon Sep 17 00:00:00 2001 From: Debanjum Date: Fri, 13 Dec 2024 12:25:23 -0800 Subject: [PATCH] Make Khoj email sender configurable for all email variants The welcome, feedback and automation emails were still using the Khoj domain, which wouldnt work for self-hosted users with their RESEND key Resolves #1004 --- src/khoj/routers/email.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/khoj/routers/email.py b/src/khoj/routers/email.py index 9d0d3600..d343861a 100644 --- a/src/khoj/routers/email.py +++ b/src/khoj/routers/email.py @@ -64,7 +64,7 @@ async def send_welcome_email(name, email): resend.Emails.send( { - "sender": "team@khoj.dev", + "sender": os.environ.get("RESEND_EMAIL", "team@khoj.dev"), "to": email, "subject": f"{name}, four ways to use Khoj" if name else "Four ways to use Khoj", "html": html_content, @@ -92,7 +92,7 @@ async def send_query_feedback(uquery, kquery, sentiment, user_email): logger.info(f"Sending feedback email for query {uquery}") - # rendering feedback email using feedback.html as template + # render feedback email using feedback.html as template template = env.get_template("feedback.html") html_content = template.render( uquery=uquery if not is_none_or_empty(uquery) else "N/A", @@ -100,10 +100,10 @@ async def send_query_feedback(uquery, kquery, sentiment, user_email): sentiment=sentiment if not is_none_or_empty(sentiment) else "N/A", user_email=user_email if not is_none_or_empty(user_email) else "N/A", ) - # send feedback from two fixed accounts + # send feedback to fixed account r = resend.Emails.send( { - "sender": "saba@khoj.dev", + "sender": os.environ.get("RESEND_EMAIL", "noreply@khoj.dev"), "to": "team@khoj.dev", "subject": f"User Feedback", "html": html_content, @@ -130,7 +130,7 @@ def send_task_email(name, email, query, result, subject, is_image=False): r = resend.Emails.send( { - "sender": "Khoj ", + "sender": f'Khoj <{os.environ.get("RESEND_EMAIL", "khoj@khoj.dev")}>', "to": email, "subject": f"✨ {subject}", "html": html_content,