From 8bbef5178796b1746a59098dd494c4207d49cdee Mon Sep 17 00:00:00 2001 From: Christoph Michael Becker Date: Tue, 13 Mar 2018 17:59:10 +0000 Subject: [PATCH] Document that $additional_headers may now be an array Cf. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@344497 c90b9560-bf6c-de11-be94-00142212c4b1 --- appendices/migration72/other-changes.xml | 10 +++++ reference/mail/functions/mail.xml | 38 ++++++++++++++++++- reference/mbstring/functions/mb-send-mail.xml | 33 +++++++++++++++- 3 files changed, 77 insertions(+), 4 deletions(-) diff --git a/appendices/migration72/other-changes.xml b/appendices/migration72/other-changes.xml index 10b102a8ac..6db74a7923 100644 --- a/appendices/migration72/other-changes.xml +++ b/appendices/migration72/other-changes.xml @@ -14,6 +14,16 @@ + + Changes to <function>mail</function> and <function>mb_sendmail</function> + + + The $additional_headers parameter of mail and + mb_sendmail now also accepts an array + instead of a string. + + + LMDB support diff --git a/reference/mail/functions/mail.xml b/reference/mail/functions/mail.xml index 7fb50ac8ae..6fd6eca8fa 100644 --- a/reference/mail/functions/mail.xml +++ b/reference/mail/functions/mail.xml @@ -13,7 +13,7 @@ stringto stringsubject stringmessage - stringadditional_headers + mixedadditional_headers stringadditional_parameters @@ -86,7 +86,7 @@ $text = str_replace("\n.", "\n..", $text); additional_headers (optional) - String to be inserted at the end of the email header. + String or array to be inserted at the end of the email header. This is typically used to add extra headers (From, Cc, and Bcc). @@ -94,6 +94,10 @@ $text = str_replace("\n.", "\n..", $text); If outside data are used to compose this header, the data should be sanitized so that no unwanted headers could be injected. + + If an array is passed, its keys are the header names and its + values are the respective header values. + additional_headers does not have mail header @@ -189,6 +193,13 @@ $text = str_replace("\n.", "\n..", $text); + + 7.2.0 + + The additional_headers parameter now also accepts + an array. + + 4.2.3 @@ -243,6 +254,29 @@ $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); +mail($to, $subject, $message, $headers); +?> +]]> + + + + Sending mail with extra headers as <type>array</type> + + This example sends the same mail as the example immediately above, but + passes the additional headers as array (available as of PHP 7.2.0). + + + 'webmaster@example.com', + 'Reply-To' => 'webmaster@example.com' + 'X-Mailer' => 'PHP/' . phpversion() +); + mail($to, $subject, $message, $headers); ?> ]]> diff --git a/reference/mbstring/functions/mb-send-mail.xml b/reference/mbstring/functions/mb-send-mail.xml index 7ff7c62009..777f193a6c 100644 --- a/reference/mbstring/functions/mb-send-mail.xml +++ b/reference/mbstring/functions/mb-send-mail.xml @@ -13,7 +13,7 @@ stringto stringsubject stringmessage - stringadditional_headers&null; + mixedadditional_headers&null; stringadditional_parameter&null; @@ -58,13 +58,17 @@ additional_headers (optional) - String to be inserted at the end of the email header. + String or array to be inserted at the end of the email header. This is typically used to add extra headers (From, Cc, and Bcc). Multiple extra headers should be separated with a CRLF (\r\n). Validate parameter not to be injected unwanted headers by attackers. + + If an array is passed, its keys are the header names and its + values are the respective header values. + When sending mail, the mail must contain @@ -130,6 +134,31 @@ + + &reftitle.changelog; + + + + + + &Version; + &Description; + + + + + 7.2.0 + + The additional_headers parameter now also accepts + an array. + + + + + + + + &reftitle.seealso;