Mail Reply for Flarum v2
Reply-by-email for Flarum 2.x. Notifications go out with a signed Reply-To header, so when users hit "Reply" in their email client, the answer becomes a real post on the discussion (with quote and a small "via email" badge).
Architecture

Highlights
- Stateless tokens. Each
Reply-To alias encodes (user, discussion, post) plus an HMAC signature. No tokens table, no expiration, no garbage collection. Old notifications stay replyable forever.
- Two delivery modes (mutually exclusive): IMAP polling inside
queue:work, or a webhook endpoint with a generated PHP pipe script (works with Exim/Postfix, Mailgun, Postmark, Cloudflare Email Workers).
- Real reply context. The new post starts with
@"author"#p{postId}, rendering the original as a proper quoted block via flarum/mentions.
- Multi-language quote stripping. Truncates the email history in PT, EN, ES, FR, DE, IT, JA, ZH, RU and others (structural detection, not keyword lists).
- Outlook threading broken on purpose. A
#{postId} suffix on the Subject makes each notification its own thread, so the Reply-To of the right email is used.
- Private discussions blocked. Threads marked
is_private (fof/byobu) are skipped on both outbound and inbound. Public discussions only, by design.
- Secrets encrypted at rest (XChaCha20-Poly1305 via libsodium). HMAC key and IMAP password never sit in plaintext on the
settings table.
Tested setup
I ran end-to-end tests using the pipe forwarder on DirectAdmin (Exim under the hood), pointing the reply mailbox at the generated PHP script. That said, the webhook endpoint is provider-agnostic: any host that can deliver inbound email to an HTTP endpoint (Mailgun routes, Postmark inbound streams, Cloudflare Email Workers, SendGrid Inbound Parse, cPanel forwarders, Plesk, custom Postfix pipes, etc.) will work the same way. The payload accepts raw RFC 822, Mailgun-style form-data, Postmark JSON, and a canonical {to, from, subject, body_text, body_html} shape.
Screenshots
Admin: General tab

Admin: IMAP tab

Admin: Webhook tab

Notification email with Reply-To alias

Reply posted back into the forum

DirectAdmin pipe forwarder configuration

Installation
composer require ramon/mail-reply
php flarum migrate
php flarum cache:clear
For IMAP mode, also install the optional library:
composer require webklex/php-imap
In admin, set the "Reply mailbox" (a dedicated address that catches +TAG aliases) and pick your delivery mode. Notifications start carrying the signed Reply-To immediately.
Links
Feedback welcome!