php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #78018 mail() expects parameter 4 to be string
Submitted: 2019-05-15 19:07 UTC Modified: 2019-05-15 19:20 UTC
From: 888 at foshin dot com Assigned:
Status: Not a bug Package: Mail related
PHP Version: 7.1.29 OS:
Private report: No CVE-ID: None
 [2019-05-15 19:07 UTC] 888 at foshin dot com
Description:
------------
---
From manual page: https://php.net/function.mail
---

"Warning: mail() expects parameter 4 to be string, array given" even though the manual says "String or array to be inserted at the end of the email header." and "If an array is passed, its keys are the header names and its values are the respective header values.".

Test script:
---------------
mail("Joe <joe@joe.com>", "Bug", ":(", array("From" => "Joe <joe@joe.com>", "To" => "Joe <joe@joe.com>", "Reply-To" => "Joe <joe@joe.com>", "X-Mailer" => "NOOOooo", "MIME-Version" => "1.0", "Content-type" => "text/html; charset=utf-8", "Date" => date("r")))

Expected result:
----------------
No warning and the mail function actually working.

Actual result:
--------------
"Warning: mail() expects parameter 4 to be string, array given"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-15 19:11 UTC] peehaa@php.net
-Status: Open +Status: Feedback
 [2019-05-15 19:11 UTC] peehaa@php.net
Are you sure you are on 7.2?
 [2019-05-15 19:16 UTC] 888 at foshin dot com
-Status: Feedback +Status: Open -PHP Version: 7.2.18 +PHP Version: 7.1.29
 [2019-05-15 19:16 UTC] 888 at foshin dot com
My host's settings page says so.. but echo phpversion(); says 7.1.29.
 [2019-05-15 19:20 UTC] peehaa@php.net
-Status: Open +Status: Not a bug
 [2019-05-15 19:20 UTC] peehaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Passing in an array is only available as of 7.2: https://php.net/function.mail#refsect1-function.mail-changelog
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 17:01:28 2024 UTC