[Web] Capture sendmail stdin in remote Playground instances - #4063
Merged
Conversation
adamziel
force-pushed
the
codex/register-sendmail-remote
branch
from
July 15, 2026 17:10
8a34311 to
6e59fca
Compare
adamziel
force-pushed
the
codex/sendmail-mail-capture
branch
from
July 15, 2026 17:21
1023fef to
49267b4
Compare
adamziel
force-pushed
the
codex/register-sendmail-remote
branch
from
July 15, 2026 17:22
6e59fca to
c2b98db
Compare
adamziel
force-pushed
the
codex/sendmail-mail-capture
branch
from
July 15, 2026 17:49
49267b4 to
24034e3
Compare
adamziel
force-pushed
the
codex/register-sendmail-remote
branch
from
July 15, 2026 17:49
c2b98db to
004de73
Compare
adamziel
force-pushed
the
codex/sendmail-mail-capture
branch
from
July 15, 2026 18:22
24034e3 to
7a67a7a
Compare
adamziel
force-pushed
the
codex/register-sendmail-remote
branch
from
July 15, 2026 18:23
004de73 to
9dbf463
Compare
adamziel
force-pushed
the
codex/sendmail-mail-capture
branch
from
July 15, 2026 19:37
7a67a7a to
8ef5dcb
Compare
adamziel
force-pushed
the
codex/register-sendmail-remote
branch
from
July 15, 2026 19:37
9dbf463 to
76e69da
Compare
adamziel
force-pushed
the
codex/sendmail-mail-capture
branch
from
July 15, 2026 19:41
8ef5dcb to
f5a59cd
Compare
adamziel
force-pushed
the
codex/register-sendmail-remote
branch
from
July 15, 2026 19:41
76e69da to
4163e1d
Compare
adamziel
added a commit
that referenced
this pull request
Jul 15, 2026
PHP can write a message to `sendmail` through `mail()`, `popen()`, or
`proc_open()`, but PHP-WASM has no reusable transport for observing
those bytes. This adds a sendmail-compatible null transport. It never
delivers mail. It emits `sendmail.spawned` with raw stdin as a live
`ReadableStream<Uint8Array>`.
Registration is explicit:
```ts
import { sendmailSpawnHandler } from '@php-wasm/util';
php.setCommandSpawnHandler('sendmail', sendmailSpawnHandler(php));
php.addEventListener('sendmail.spawned', async (event) => {
if (event.type !== 'sendmail.spawned') {
return;
}
const rawMessage = await new Response(event.stdin).arrayBuffer();
// Parse or relay rawMessage.
});
```
The event fires with the first stdin chunk, before PHP finishes writing.
The transport stays alive until stdin closes. Empty input exits with
`EX_TEMPFAIL` and emits no event. Input above 20 MB errors the stream
and exits with status 1. Cancelling the stream stops delivery to that
reader but keeps draining stdin, so PHP can finish writing and receive
the transport's exit status. There is no backpressure to PHP; a slow
listener may buffer the full message.
Node tests cover `mail()`, `proc_open()`, delayed input, empty and
oversized input, and runtime rotation. Browser tests cover live delivery
to multiple listeners and cancellation while PHP continues writing.
This PR does not install the transport by default. #4063 installs it in
remote Playground instances.
#4064 provides the marked stdin event transport and per-listener streams
used here.
Co-authored-by: Adam Zieliński <adam@adamziel.com>
adamziel
force-pushed
the
codex/register-sendmail-remote
branch
from
July 15, 2026 20:09
4163e1d to
6868c43
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
sendmailSpawnHandler()(introduced in #3996) to PHP.wasm objects instantiated in theremote.htmlweb worker. The handler catches any emails sent by WordPress and re-exposes it through an event listener as follows:The goal is to expose these emails in the UI in a follow-up PR.