diff --git a/.env.example b/.env.example index c5bfbe2..50d6cc1 100644 --- a/.env.example +++ b/.env.example @@ -2,5 +2,6 @@ ACCOUNT_DEFAULT_HTTP_PROTOCOL=http ALLOWED_HOSTS=* DEBUG=on EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend +EMAIL_SENDGRID_REPLY_TO=reply-to@fakesendgrid.com PYTHONUNBUFFERED=1 SECRET_KEY="django-insecure-l@1xnj747ei)9ex(0zkfyy6zv@&*=i$wi9722=ji7)+s^_kuvy" diff --git a/journal/entries/jobs/send_mail.py b/journal/entries/jobs/send_mail.py index cc18dc0..13141b0 100644 --- a/journal/entries/jobs/send_mail.py +++ b/journal/entries/jobs/send_mail.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.core import mail from django.template.loader import render_to_string from django.utils import timezone @@ -22,6 +23,6 @@ def execute(self): subject=f"It's {today:%A}, {today:%b}. {today:%-d}, how are you?", message=text_message, html_message=html_message, - from_email="who is this from email", + from_email=settings.EMAIL_SENDGRID_REPLY_TO, recipient_list=[account.user.email], ) diff --git a/journal/entries/tests/test_jobs.py b/journal/entries/tests/test_jobs.py index db5fbb4..d4cabe1 100644 --- a/journal/entries/tests/test_jobs.py +++ b/journal/entries/tests/test_jobs.py @@ -1,4 +1,5 @@ import time_machine +from django.conf import settings from journal.accounts.tests.factories import UserFactory from journal.entries.jobs.send_mail import Job as SendMailJob @@ -18,7 +19,7 @@ def test_send_email(self, mailoutbox): assert len(mailoutbox) == 1 mail = mailoutbox[0] - # TODO: assert from_email + assert mail.from_email == settings.EMAIL_SENDGRID_REPLY_TO assert mail.to == [user.email] assert mail.subject == "It's Wednesday, Jul. 19, how are you?" assert entry.body in mail.body # Test the text email. diff --git a/project/settings.py b/project/settings.py index 5a478ad..e9ffffd 100644 --- a/project/settings.py +++ b/project/settings.py @@ -121,6 +121,7 @@ # Email EMAIL_BACKEND = env("EMAIL_BACKEND") +EMAIL_SENDGRID_REPLY_TO = env("EMAIL_SENDGRID_REPLY_TO") # Internationalization # https://docs.djangoproject.com/en/4.2/topics/i18n/