|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-08-21 00:47 UTC] ta_chi at nyc dot odn dot ne dot jp
Description:
------------
In function 'mail()', a 'Warning' occurred depending on the combination of mail-headers to be specified, and not be sent.
But, if at least one is missing, it succeed.
That actual elements, please see the test script.
I know that "mb_send_mail()" does not support "quoted-printable".
However, I think that there is a discrepancy in behavior.
Emvironment
Apache/2.4.27 (Win64) PHP/5.6.36, and, Apache/2.4.27 (Win64) PHP/7.0.30
Target MTA is IIS SMTP Service.
Test script:
---------------
<?php
error_reporting(E_ALL|E_STRICT);
ini_set("display_errors", "On");
echo mb_language('uni');
$sendto = "address@example.com";
$subject = "[Test]Subject";
$msg = "=E3=83=86=E3=82=B9=E3=83=88=E6=9C=AC=E6=96=87";
// If these elements combination exists in the code, an error will occur.
// But, even if at least one element is missing, it succeeds.
$headers = [
"MIME-Version: 1.0"
, "Content-Type: text/plain; charset=utf-8"
, "Content-Transfer-Encoding: quoted-printable"
, "" /* and empty string. */];
echo mail($sendto, $subject, $msg, implode("\r\n", $headers)) . "<br/>\n";
// -> "Warning: mb_send_mail(): Multiple or malformed newlines found in additional_header in xxx.php on line xx"
// Or, even if the newline-code is limited to LF, it will succeed.
echo mail($sendto, $subject, $msg, implode("\n", $headers)) . "<br/>\n";
Expected result:
----------------
Mail will be sent.
Actual result:
--------------
Mail was not sent.
An error occurred.
> "Warning: mb_send_mail(): Multiple or malformed newlines found in additional_header in xxx.php on line xx"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
> PHP 7.0 is not in active support. Please try with 7.1 or later. I checked it. It was the same situation in 7.1.21 too. > > But, if at least one is missing, it succeed. > Example? // fail $headers = [ "MIME-Version: 1.0" , "Content-Type: text/plain; charset=utf-8" , "Content-Transfer-Encoding: quoted-printable" , ""]; // success $headers = [ "Content-Type: text/plain; charset=utf-8" , "Content-Transfer-Encoding: quoted-printable" , ""]; // success $headers = [ "MIME-Version: 1.0" , "Content-Transfer-Encoding: quoted-printable" , ""]; // success, but, body text is garbled. $headers = [ "MIME-Version: 1.0" , "Content-Type: text/plain; charset=utf-8" , ""]; // success $headers = [ "MIME-Version: 1.0" , "Content-Type: text/plain; charset=utf-8" , "Content-Transfer-Encoding: quoted-printable"];As the reported warning shows, you are using the MBString function overload “feature” (which is deprecated as of PHP 7.2.0, by the way). I can reproduce the reported warning, if I add: mb_language('Japanese'); However, I also get: Warning: mb_send_mail(): Unsupported transfer encoding "quoted-printable" - will be regarded as 8bit in %s