Skip to content

Stdlib: mail() — send message via sendmail/MTA (ext/standard/mail.c parity) #3285

Description

@PurHur

Category

stdlib

Problem

mail() is missing. Many PHP apps use it for simple outbound email (web forms, alerts). php-src implements it in ext/standard (not a separate extension).

function_exists('mail') is false under bin/vm.php (verified 2026-06-04).

Duplicate tracker: consolidate with #5092 — implement on this issue (#3285); close #5092 when merged.

php-src reference

Repro (failure today)

<?php
if (!function_exists('mail')) {
    fwrite(STDERR, "MISSING: mail\n");
    exit(1);
}
$ok = @mail(
    'user@example.com',
    'Subject',
    "Body line\n",
    "From: noreply@example.com\r\n"
);
var_export($ok);
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php8.2 -r "var_export(function_exists(\"mail\")); echo PHP_EOL;"
php bin/vm.php -r "var_export(function_exists(\"mail\")); echo PHP_EOL;"
php bin/vm.php repro.php
'
Runtime function_exists('mail') repro exit
Zend true var_export bool (may be false without MTA)
VM false exit 1 MISSING: mail

php-src-strict probes (after implementation)

  • Non-string $to / $subjectTypeError per mail.c
  • Invalid additional headers → ValueError / E_WARNING per Zend version

Scope (PHP-in-PHP)

Path Work
ext/standard/mail.php VM builtin; v1 delegate to host mail() when available (bootstrap), native sendmail pipe follow-up
ext/standard/Module.php Register
Tests test/compliance/cases/stdlib/mail_exists.phpt (existence + arg validation subset)
Matrix script/capability-matrix.php

No permanent mail transport logic in runtime/*.c unless thin sendmail pipe ABI is unavoidable.

Done when

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions