Skip to content

Always send email from the configured sender; staff set Reply-To - #185

Merged
pancakereport merged 4 commits into
mainfrom
email-fixed-sender
Nov 18, 2026
Merged

pancakereport merged 4 commits into
mainfrom
email-fixed-sender

Conversation

@pancakereport

@pancakereport pancakereport commented Nov 18, 2026 •

Copy link
Copy Markdown

Closes #179

The email page had a FROM field, and mail went out through the university's SMTP account with whatever address staff typed there. Now every email is sent from the configured sender (EMAIL_SENDER), and staff can set an optional Reply-To so replies still reach the course (for example a course SPA's address).

Changes

  • From is fixed. Emails to students and test emails both use EMAIL_SENDER as From. A from_addr sent with the form is ignored.
  • Reply-To. The form's from_addr field is replaced by reply_to: optional, and if given it must be a single valid address. Surrounding whitespace is stripped. construct_email adds a Reply-To header only when one is given.
  • No sender, no email. If EMAIL_SENDER is unset, empty or blank, emails would go out with an empty From. Instead:
    • the page says no sender is set up and disables the send and send-test buttons
    • a post anyway is refused before anything is sent
    • building an email without a sender raises
  • Page. FROM shows the sender as a read-only input with no name, so it isn't submitted. REPLY-TO sits next to it, and TO now has its own row.
  • CC and BCC are unchanged, as the issue asks.
  • TestingConfig sets a sender, so tests don't depend on the local environment. .env.sample says what EMAIL_SENDER is used for.

Tests

New tests/unit/test_email_sender.py:

  • student emails and test emails are sent from the sender, with the staff Reply-To
  • a forged from_addr never shows up in the message, through the batch endpoint, the full-page form or the single-student form
  • Reply-To is optional and stripped, and an invalid address or a list is an error on reply_to
  • with the sender unset, empty or blank: the batch endpoint, full-page send, test send and single-student send all send nothing and say why, and the page disables its send buttons
  • the page shows the sender read-only and doesn't submit it

Existing email tests post reply_to instead of from_addr, and the e2e tests type into reply_to.

All unit tests and the email e2e and a11y tests pass locally. The one exception is test_dev_login.py::TestRealCanvas::test_login_redirects_to_real_canvas, which fails the same way on main with my local .env.

🤖 Generated with Claude Code

The email page let staff type any From address, and mail went out through
the university's SMTP account under it. Now every email (to students and
test emails) is sent from EMAIL_SENDER, which the page shows read-only.
Staff can set an optional Reply-To so replies still reach the course. CC
and BCC are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🚀 Staging Preview Deployed!

URL: https://preview-seating-pr-185-137456085712.us-west1.run.app

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.97%. Comparing base (604aac7) to head (6d1b933).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #185      +/-   ##
==========================================
+ Coverage   92.70%   92.97%   +0.26%     
==========================================
  Files          36       36              
  Lines        2756     2774      +18     
==========================================
+ Hits         2555     2579      +24     
+ Misses        201      195       -6     
Flag Coverage Δ
e2e 33.46% <26.08%> (-0.12%) ⬇️
unit 92.97% <100.00%> (+0.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

pancakereport and others added 3 commits November 18, 2026 12:53
Without EMAIL_SENDER, emails would have gone out with an empty From. The
email pages now say no sender is set up and disable the send buttons; a
post anyway is refused before anything is sent, and building an email
without a sender raises. Reply-To is stripped of surrounding whitespace.

Tests cover an unset, empty and blank sender on every send path, a forged
From through the full-page and single-student forms, and that a list in
Reply-To is an error on that field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pancakereport
pancakereport merged commit c8cbda2 into main Nov 18, 2026
15 checks passed
@pancakereport
pancakereport deleted the email-fixed-sender branch November 18, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Staff can send email from the university account with any From

1 participant