Skip to content

Commit

Permalink
Set from email in email sending job.
Browse files Browse the repository at this point in the history
For #4
  • Loading branch information
mblayman committed Jul 27, 2023
1 parent 6fab114 commit 154c4d7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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=[email protected]
PYTHONUNBUFFERED=1
SECRET_KEY="django-insecure-l@1xnj747ei)9ex(0zkfyy6zv@&*=i$wi9722=ji7)+s^_kuvy"
3 changes: 2 additions & 1 deletion journal/entries/jobs/send_mail.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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],
)
3 changes: 2 additions & 1 deletion journal/entries/tests/test_jobs.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down

0 comments on commit 154c4d7

Please sign in to comment.