Skip to contentSkip to conversation

layerindex/views.py: tweak from_email

PATCH New [email protected] 1 participant 1 message Aug 18, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 layerindex/views.py: tweak from_email

From: Tim Orling <[email protected]>

In production, we use settings.DEFAULT_FROM_EMAIL as our primary source of from_email, rather than settings.SUBMIT_EMAIL_FROM

Default to DEFAULT_FROM_EMAIL if it is not Null, fall back to SUBMIT_EMAIL_FROM

The real consumer (in production) is a Celery task in layerindex/tasks.py

@tasks.task
def send_email(subject, text_content, from_email=settings.DEFAULT_FROM_EMAIL, to_emails=[]):

---
 layerindex/views.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
layerindex/views.py +1 -1
index c7a1f09..4df2a09 100644
@@ -1672,7 +1672,7 @@ def email_test_view(request):
         'help_contact': _get_help_contact(),
     }
     subject = '%s: test email' % site_name
-    from_email = settings.SUBMIT_EMAIL_FROM
+    from_email = settings.DEFAULT_FROM_EMAIL if settings.DEFAULT_FROM_EMAIL else settings.SUBMIT_EMAIL_FROM
     to_email = request.user.email
     text_content = plaintext.render(d)
     tasks.send_email.apply_async((subject, text_content, from_email, [to_email]))
Signature · 1 line
2.46.0