From 621967d2b62e9516f2219b468073d2ce7398d391 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 16 Jan 2024 06:53:03 +0100 Subject: [PATCH] Add MAIL_FROM env variable (#949) Co-authored-by: Roman Tyshyk --- backend/danswer/auth/users.py | 2 ++ backend/danswer/configs/app_configs.py | 1 + deployment/docker_compose/docker-compose.dev.yml | 1 + deployment/docker_compose/env.prod.template | 2 ++ deployment/kubernetes/env-configmap.yaml | 1 + 5 files changed, 7 insertions(+) diff --git a/backend/danswer/auth/users.py b/backend/danswer/auth/users.py index 82697917a..eec3b0282 100644 --- a/backend/danswer/auth/users.py +++ b/backend/danswer/auth/users.py @@ -38,6 +38,7 @@ from danswer.configs.app_configs import SMTP_PASS from danswer.configs.app_configs import SMTP_PORT from danswer.configs.app_configs import SMTP_SERVER from danswer.configs.app_configs import SMTP_USER +from danswer.configs.app_configs import MAIL_FROM from danswer.configs.app_configs import VALID_EMAIL_DOMAINS from danswer.configs.app_configs import WEB_DOMAIN from danswer.configs.constants import AuthType @@ -111,6 +112,7 @@ def send_user_verification_email(user_email: str, token: str) -> None: msg = MIMEMultipart() msg["Subject"] = "Danswer Email Verification" msg["To"] = user_email + msg["From"] = MAIL_FROM link = f"{WEB_DOMAIN}/auth/verify-email?token={token}" diff --git a/backend/danswer/configs/app_configs.py b/backend/danswer/configs/app_configs.py index 89646264c..31cd06067 100644 --- a/backend/danswer/configs/app_configs.py +++ b/backend/danswer/configs/app_configs.py @@ -81,6 +81,7 @@ SMTP_SERVER = os.environ.get("SMTP_SERVER") or "smtp.gmail.com" SMTP_PORT = int(os.environ.get("SMTP_PORT") or "587") SMTP_USER = os.environ.get("SMTP_USER", "your-email@gmail.com") SMTP_PASS = os.environ.get("SMTP_PASS", "your-gmail-password") +MAIL_FROM = os.environ.get("EMAIL_FROM", SMTP_USER) ##### diff --git a/deployment/docker_compose/docker-compose.dev.yml b/deployment/docker_compose/docker-compose.dev.yml index 56deb78d6..bd627ee8f 100644 --- a/deployment/docker_compose/docker-compose.dev.yml +++ b/deployment/docker_compose/docker-compose.dev.yml @@ -27,6 +27,7 @@ services: - SMTP_PORT=${SMTP_PORT:-587} # For sending verification emails, if unspecified then defaults to '587' - SMTP_USER=${SMTP_USER:-} - SMTP_PASS=${SMTP_PASS:-} + - MAIL_FROM=${MAIL_FROM:-} # Gen AI Settings - GEN_AI_MODEL_PROVIDER=${GEN_AI_MODEL_PROVIDER:-openai} - GEN_AI_MODEL_VERSION=${GEN_AI_MODEL_VERSION:-gpt-3.5-turbo} diff --git a/deployment/docker_compose/env.prod.template b/deployment/docker_compose/env.prod.template index 190630f6c..06d546606 100644 --- a/deployment/docker_compose/env.prod.template +++ b/deployment/docker_compose/env.prod.template @@ -47,6 +47,8 @@ SECRET= # The below are only needed if you aren't using gmail as your SMTP #SMTP_SERVER= #SMTP_PORT= +# when missing SMTP_USER used instead +#MAIL_FROM= # OpenID Connect (OIDC) #OPENID_CONFIG_URL= diff --git a/deployment/kubernetes/env-configmap.yaml b/deployment/kubernetes/env-configmap.yaml index a296fed30..ca0fa21ae 100644 --- a/deployment/kubernetes/env-configmap.yaml +++ b/deployment/kubernetes/env-configmap.yaml @@ -11,6 +11,7 @@ data: SMTP_PORT: "" # For sending verification emails, if unspecified then defaults to '587' SMTP_USER: "" # 'your-email@company.com' SMTP_PASS: "" # 'your-gmail-password' + MAIL_FROM: "" # 'your-email@company.com' SMTP_USER missing used instead # Gen AI Settings GEN_AI_MODEL_PROVIDER: "openai" GEN_AI_MODEL_VERSION: "gpt-3.5-turbo" # Use GPT-4 if you have it