From d3db6eed76486847ce1a8b77a8ac841fb4e051cb Mon Sep 17 00:00:00 2001 From: Ryan Westfall Date: Sun, 9 Aug 2026 07:23:47 -0500 Subject: [PATCH] Document compose-safe DEFAULT_FROM_EMAIL quoting. Docker Compose .env rejects "Name" ; prefer a bare address or one pair of quotes around the whole From value. --- .env.example | 12 ++++++------ .env.prod.example | 7 ++++--- site/monica_site/settings/base.py | 8 ++++++++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index e714ceb..7cb9875 100644 --- a/.env.example +++ b/.env.example @@ -31,12 +31,12 @@ EMAIL_HOST_USER= EMAIL_HOST_PASSWORD= EMAIL_PORT=2525 EMAIL_USE_TLS=true -# Inbox From header. Bare address → local-part shows as name ("noreply"). -# Prefer quoted display name (SITE_NAME is auto-wrapped if you omit it): -# DEFAULT_FROM_EMAIL=noreply@mkdrealtor.com -# → "Monica Dhillon" -# Or set explicitly (must be allowed/verified in SMTP2GO): -# DEFAULT_FROM_EMAIL="Monica Dhillon" +# Inbox From header. Docker Compose .env cannot parse: "Name" +# (the breaks the parser). Use ONE of: +# DEFAULT_FROM_EMAIL=notifications-beta@mkdrealtor.com +# → app wraps with SITE_NAME → "Monica Dhillon" +# DEFAULT_FROM_EMAIL="Monica Dhillon " +# → whole value in one pair of quotes (compose-safe) DEFAULT_FROM_EMAIL=noreply@mkdrealtor.com # Console (default in DJANGO_ENV=dev) prints mail to container logs. # For real SMTP2GO delivery locally, uncomment: diff --git a/.env.prod.example b/.env.prod.example index cface3f..ff09205 100644 --- a/.env.prod.example +++ b/.env.prod.example @@ -24,9 +24,10 @@ SITE_UNDER_CONSTRUCTION=true SITE_NAME=Monica Dhillon SITE_TAGLINE=MKDRealtor.com · EXIT Realty Redefined PUBLIC_SITE_URL=https://mkdrealtor.com -# Inbox From (display name auto-added from SITE_NAME if omitted). -# SMTP2GO must allow sending as this address. Example: -# DEFAULT_FROM_EMAIL="Monica Dhillon" +# Inbox From. Docker Compose .env: do NOT use "Name" (breaks parse). +# Prefer bare address (SITE_NAME auto-wrapped) OR one quoted string: +# DEFAULT_FROM_EMAIL=notifications-beta@mkdrealtor.com +# DEFAULT_FROM_EMAIL="Monica Dhillon " DEFAULT_FROM_EMAIL=noreply@mkdrealtor.com CONTACT_PHONE= CONTACT_EMAIL= diff --git a/site/monica_site/settings/base.py b/site/monica_site/settings/base.py index 191f3b6..c650d83 100644 --- a/site/monica_site/settings/base.py +++ b/site/monica_site/settings/base.py @@ -221,10 +221,18 @@ def format_from_email(address: str | None, display_name: str | None = None) -> s Bare ``noreply@…`` shows as "noreply". Prefer ``"Monica Dhillon" `` (RFC 5322). + + Docker Compose ``.env`` cannot parse split quotes like + ``"Name" `` — use a bare address (this helper adds SITE_NAME) + or one pair of quotes around the whole value: + ``DEFAULT_FROM_EMAIL="Monica Dhillon "``. """ raw = (address or "").strip() if not raw: return "" + # Strip a single layer of wrapping quotes from env/compose. + if len(raw) >= 2 and raw[0] == raw[-1] and raw[0] in {'"', "'"}: + raw = raw[1:-1].strip() if "<" in raw and ">" in raw: return raw name = (display_name or SITE_NAME or "").strip()