Forums Feature Requests Thread

[New Feature] Email-to-post and reply-by-email

Patrick Bass · May 24 · 30 · 1 Locked
[Deployed to Production]
🚀 OP May 24, 2026 7:52pm

Type: New Feature

Priority: P2

What: Members can reply to notification emails and have their reply posted as a forum reply. ADR-0018 exists as a design doc. Uses existing inbound mail infrastructure.

Who benefits: Members (convenience, especially mobile users who prefer email).

Why: Discourse's killer feature for engagement. Reduces friction to zero for replies.

Complexity: Medium


Patrick Bass
@mobieus

🚀 May 29, 2026 2:21pm

Shipped (2026-05-29, commit e0f57ec0). Code is ready; activation needs two short ops steps.

What is in the code

  • App\Services\MailReplyToken — stateless HMAC token; format reply+<slug>+<thread-id>+<base64url payload>+<base64url sig>. Payload carries the recipient user-id + a 30-day expiry. Secret is the per-tenant APP_SECRET_KEY; rotation invalidates every outstanding token at once.
  • MailService::send and EmailQueue::enqueue grew an optional $replyTo parameter. processQueue stashes the address in template_data as __reply_to and forwards on send. Zero schema change.
  • ForumController builds the token at the forum-reply notification site. Falls back silently to no Reply-To if MAIL_REPLY_DOMAIN / APP_SECRET_KEY / TENANT_SLUG are not all set.
  • bin/process-mail-inbox.php — CronTracker-wrapped IMAP worker. Pulls UNSEEN, validates the HMAC via per-tenant cred file under /etc/mobieus-io/tenant-creds/<slug>.env, opens the right tenant DB, strips quoted lines + signatures, INSERTs a forum_post attributed to the token user. Updates reply_count + last_post_at. Marks message Seen.
  • cron_jobs row id=32 process-mail-inbox, schedule * * * * *, enabled=0 by default. Flip it on after the two ops steps below.
  • scripts/cron.d/mobieus-platform-admin-mail-inbox + matching fan-out wrapper with flock to prevent overlapping runs.
  • app.ini.dist [mail_bridge] block documents every env var with sample values.

Two ops steps to activate

  1. Install php-imap on the platform host:
    apt-get install php8.3-imap && systemctl reload php8.3-fpm
  2. Populate the IMAP creds in env (the worker reads from $_ENV):
    MAIL_REPLY_DOMAIN=mobieus.io
    MAIL_REPLY_INBOX_HOST=mail.mobieus.io
    MAIL_REPLY_INBOX_USER=support@mobieus.io (or a dedicated replybot@)
    MAIL_REPLY_INBOX_PASS=…
    MAIL_REPLY_INBOX_PORT=993
    MAIL_REPLY_INBOX_FOLDER=INBOX

Worker exits cleanly if either step is missing — verified by running it on the live host: [mail-bridge] php-imap extension not installed; aborting cleanly.

Out of scope (v1)

  • Reply-by-email for DMs (forum replies first; DMs can come next).
  • Post-by-email to start a NEW thread (this v1 is reply-only).
  • Attachments (current worker drops them silently; v2 can route to per-tenant uploads).
  • Outbound From: that matches the real member email (sender authentication / SPF / DKIM impersonation is a separate problem).

Patrick Bass
@mobieus

Log in or register to reply to this thread.