mb_send_mail

FunctionParams and return types changed in PHP 8.0

Send encoded mail.

PHP 5
PHP 7
PHP 8.0
Improved
PHP 8.1
PHP 8.2-8.3
PHP 8.4
PHP 8.5
PHP 8.6

mb_send_mail Function synopsis

mb_send_mail(
    string $to,
    string $subject,
    string $message,
    array|string $additional_headers = [],
    ?string $additional_params = null
  ): bool

Parameters

$to

Typestring

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

Typestring

The subject of the mail.

$message

Typestring

The message of the mail.

$additional_headers

OptionalTypearray|stringDefault value[]

string or array to be inserted at the end of the email header.

$additional_params

OptionalType?stringDefault valuenull

$additional_params is a MTA command line parameter. It is useful when setting the correct Return-Path header when using sendmail.

Return value

Typebool

Returns true on success, false on failure

Changes to the mb_send_mail Function

PHP 8.0

  • Return type added: bool
  • Parameter type added for parameter #1 ($to): string
  • Parameter type added for parameter #2 ($subject): string
  • Parameter type added for parameter #3 ($message): string
  • Parameter type added for parameter #4 ($additional_headers): array|string
  • Parameter default value added for position #4 ($additional_headers): []
  • Parameter name of parameter #5 changed: $additional_parameters to $additional_params
  • Parameter type added for parameter #5 ($additional_params): ?string
  • Parameter default value added for position #5 ($additional_params): null
  mb_send_mail(
-     $to,
+     string $to,
-     $subject,
+     string $subject,
-     $message,
+     string $message,
-     $additional_headers,
+     array|string $additional_headers = [],
-     $additional_parameters
+     ?string $additional_params = null
-   )
+   ): bool

mb_send_mail Function Availability

PHP VersionAvailability
PHP 8.6Upcoming Release Yes
PHP 8.5Supported (Latest) Yes
PHP 8.4Supported Yes
PHP 8.3Security-Fixes Only Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Unsupported Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported Yes
PHP 7.3Unsupported Yes
PHP 7.2Unsupported Yes
PHP 7.1Unsupported Yes
PHP 7.0Unsupported Yes
PHP 5.6Unsupported Yes
PHP 5.5Unsupported Yes
PHP 5.4Unsupported Yes
PHP 5.3Unsupported Yes