Repository navigation
Conversation
f8e769e to
c37001e
Compare
c37001e to
e9ea3f3
Compare
| }; | ||
| } | ||
|
|
||
| function getEnvelopeSender(command: string[]) { |
There was a problem hiding this comment.
Let's add simple docs what this does.
| : typeof command === 'string' | ||
| ? (splitShellCommand(command)[0] ?? '') | ||
| : ''; | ||
| const bin = basename(cmdStr); |
There was a problem hiding this comment.
Here we could improve the const naming.
| } | ||
|
|
||
| if (loaderOptions.withMailCapture) { | ||
| emscriptenOptions = withMailCapture( |
There was a problem hiding this comment.
This sets the spawnProcess option, but Playground will probably override it in
| return; | ||
| } | ||
|
|
||
| if (stdin.bytes.length > 0) { |
There was a problem hiding this comment.
Should this be silent or emit an error? Or should we call the fallback even with no bytes?
…ableMailCapture and update related tests
|
This PR should enable us to start working on a UI for email on the website and it's working, but I'm unhappy with how it overrides the spawn handler. A alternative to the current approach are creating a stack of spawn handler overrides, but that's too complex for what we need and could be messy to add more spawn handlers. For example if I want to replace the default, or need to ensure that handler B goes after handler A. A simpler option (I'm exploring it now) would be to always capture email and leave the spawn handler as is. |
## Summary Adds shared Base64 helpers to `@php-wasm/util`. ## Motivation for the change, related issues Playground currently has several small Base64 implementations spread across packages. The SMTP stack needs byte-oriented Base64 helpers for protocol-level authentication challenges and responses, so this PR centralizes those helpers before the SMTP protocol engine lands. This sits after #3956 in the SMTP review stack. #3956 proves PHP mail bytes can be captured raw; this PR adds shared Base64 utilities used by #3953's SMTP AUTH support and existing callers. ## Implementation details - Moves `decodeBase64ToString`, `decodeBase64ToUint8Array`, `encodeStringAsBase64`, and `encodeUint8ArrayAsBase64` to `@php-wasm/util`. - Updates call sites to import the shared helpers. - Updates `encodeUint8ArrayAsBase64` to support arrays with more than 65536 arguments without triggering a `RangeError`. The MIME parser work later in the stack no longer depends on these helpers; it is delegated to `postal-mime` in #3953. ## Testing Instructions Run the focused utility tests: ```bash npm exec nx test php-wasm-util -- --runInBand ``` Co-authored-by: Ashish Kumar <ashfame@users.noreply.github.com>
Summary
Adds raw outbound mail capture plumbing for PHP runtimes without parsing the captured bytes.
Motivation for the change, related issues
This is the first SMTP-stack layer after #3951. Once PHP can route write-side
popen()/pclose()through wasm wrappers, Playground can intercept the bytes PHP writes to sendmail. This PR proves that raw stream can be captured, but intentionally does not parse headers, MIME bodies, attachments, or SMTP socket sessions.Implementation details
ProcessApi.readStdin().createSendmailCaptureSpawnHandler(), which intercepts sendmail commands and reports raw stdin bytes plus command metadata.withMailCapture()in@php-wasm/universaland exposes it through the node and web runtime loaders.mail()and direct sendmailproc_open()calls can be captured as raw bytes.This deliberately leaves SMTP protocol handling and MIME parsing to later PRs in the stack.
Testing Instructions
Run the utility tests and raw mail capture runtime test: