Skip to content

Screen inbound support mail (#1899) - #1968

Merged
neuromechanist merged 10 commits into
devfrom
feature/issue-1899-mail-screening
Oct 26, 2026
Merged

neuromechanist merged 10 commits into
devfrom
feature/issue-1899-mail-screening

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Four protections for inbound support mail, in one change (#1893 follow-up, #1899, ADR 0113):

  • Sender blocklist (mail_blocklist): a listed address, or a domain with its subdomains, is rejected at delivery before anything is stored. Lookup failure fails open. Our own domain and shared mailbox providers cannot be domain-blocked; our own addresses cannot be blocked at all.
  • Bulk, automatic-reply and bounce mail is stored with mail_tickets.filtered: open but never assigned or announced, hidden from the default list and the unread badge, and appended without a notice or a reopen when it threads into an existing ticket. Spam still wins.
  • Per-sender hourly cap (MAIL_SENDER_HOURLY_CAP, default 20): overflow is filed as rate_limited.
  • Quiet queues (mail_queues.notify): no creation notice; escalation notices still go out.

Routes: GET/POST /admin/mail/blocklist, DELETE /admin/mail/blocklist/:id, POST /admin/mail/tickets/:id/spam, filtered list filter, notify on queues. CLI: nemar admin mail spam, blocklist [add|remove], list --filtered, queues set --notify.

Migration 0111_mail_screening.sql. Contract changes for the website transcription (shared/contract/mail-admin.ts):

  • New closed lists: FILTER_REASONS, FILTERED_LIST_MODES, BLOCK_KINDS, SPAM_BLOCK_CHOICES.
  • New error codes: block_not_allowed (422), block_sender_unverified (422).
  • TicketSummary.filtered; ListTicketsQuery.filtered; MailQueue.notify; PutQueueRequest.notify.
  • SpamRequest { block, reason?, force? }, SpamResponse, BlocklistEntry, ListBlocklistQuery/Response, AddBlockRequest/Response, RemoveBlockResponse.
  • Ticket event kind unfiltered (migration 0111 rebuilds mail_ticket_events for it).

Review round 1: a person's action (reply, note, assign, status, escalate) or a genuine message from someone on the ticket clears filtered; the hourly cap counts only DMARC-passing mail; X-Auto-Response-Suppress is no longer read; the default list hides filtered tickets only when no status, assignee or search is given; public suffixes and more shared providers cannot be domain-blocked; blocking an unverified sender is refused (domain) or needs --force (address); spam defaults to --block none; the block and the status change are one batch.

Test plan

  • bun run typecheck, bun run lint
  • Full backend suite (8727 pass), including new backend/test/mail-screening.test.ts (38 tests: real D1, real postal-mime, Miniflare R2, real admin router, recording send binding)
  • test/admin-mail-cli.test.ts (67 pass, 5 new), route inventory, ADR index, API export surface
  • After deploy to staging, send a bulk-headed message and a message from a blocked address

Operator step

After deploy: nemar admin mail queues set '*' --notify false

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR1968

Version: 0.10.25-PR1968.c322116
Commit: c322116


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit e3e5ddc into dev Oct 26, 2026
20 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-1899-mail-screening branch October 26, 2026 07:37
This was referenced Oct 26, 2026

This branch was previously deployed

1 inactive deployment
npm — c3221163 Deployed Oct 26, 2026 by neuromechanist via publish #4013
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.

1 participant