Home > Backend Development > PHP Tutorial > Why is PHP\'s `mail()` Function Throwing \'Multiple or Malformed Newlines Found in Additional_header\'?

Why is PHP\'s `mail()` Function Throwing \'Multiple or Malformed Newlines Found in Additional_header\'?

Linda Hamilton
Release: 2024-11-21 06:30:08
Original
853 people have browsed it

Why is PHP's `mail()` Function Throwing

"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:

  • Remove unnecessary newlines: Eliminate all multiple or malformed newlines from the additional_headers argument.
  • Separate headers from message: Utilize the message argument exclusively for the email body, including multiparts or attachments. Headers should be confined to the additional_headers argument.

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template