mb_send_mail()
mb_send_mail() — Send encoded mail.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Sends email. Headers and messages are converted and encoded according to the mb_language() setting. It's a wrapper function for mail(), so see also mail() for details.
Signature
mb_send_mail(string $to, string $subject, string $message, array|string $additional_headers = [], ?string $additional_params = null): bool
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $to | string | The mail addresses being sent to. Multiple recipients may be specified by putting a comma between each address in to. This parameter is not automatically encoded. |
| $subject | string | The subject of the mail. |
| $message | string | The message of the mail. |
| $additional_headers (optional) | mixed | String or array to be inserted at the end of the email header. |
| $additional_params | ?string | additional_params is a MTA command line parameter. It is useful when setting the correct Return-Path header when using sendmail. |
Return value
Returns true on success or false on failure.
Example
The PHP manual ships no example for mb_send_mail(); the signature and the parameter table above are the contract.
Changelog
| Version | Change |
|---|---|
| 8.0.0 | additional_params is nullable now. |
| 7.2.0 | The additional_headers parameter now also accepts an array. |
See also
mail(), mb_encode_mimeheader(), mb_language()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page mb_send_mail() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.