"Error with PHP mail(): Multiple or Malformed Newlines Found in Additional_header" Explained
Recently, numerous PHP developers have encountered the perplexing "Multiple or Malformed Newlines Found in Additional_header" error when sending emails. Despite no script modifications, this issue has abruptly appeared for many. The culprit behind this error lies in recent updates made to PHP versions.
Previously, PHP tolerated additional newlines within additional_headers. However, to mitigate a security vulnerability, PHP has tightened its restrictions. Any newlines within the additional_headers argument are now considered "multiple or malformed." This means that headers must be fully sanitized, excluding any redundant newlines.
Furthermore, the message body should be placed in the message argument, not the additional_headers argument. Any attempt to include the email message within additional_headers will also trigger this error.
Solution:
To resolve this issue, follow these steps:
By implementing these changes, you can avoid the "Error with PHP mail(): Multiple or Malformed Newlines Found in Additional_header" and successfully send emails using PHP's mail() function.
For detailed information, refer to the PHP Security Bug report: https://bugs.php.net/bug.php?id=68776
The above is the detailed content of Why is PHP\'s `mail()` Function Throwing \'Multiple or Malformed Newlines Found in Additional_header\'?. For more information, please follow other related articles on the PHP Chinese website!