مشكلة غريبة مع بريد PHP () تحت Linux
سؤال
هذا هو الحال عندما يعمل على جهازي ". إلا أن جهازي هو Windows، والهدف هو نوع من لينكس.
الفكرة هي أن mail()
وظيفة تضع خط جديد بين MIME-Version
و Content-Type
رؤوس، وبالتالي كسر كل شيء. إليك الرمز، أبساه أكبر قدر ممكن:
<?php
$HTMLPart = chunk_split(base64_encode('<html><body style="color: red">Test.</body></html>'));
$PlaintextPart = chunk_split(base64_encode('>>> TEST <<<'));
$Headers =<<<AKAM
From: "My Test" <my@mail.com>
Reply-To: my@mail.com
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="9-1410065408-1410065408=:27514"
AKAM;
$Body =<<<AKAM
This is a multi-part message in MIME format.
--9-1410065408-1410065408=:27514
Content-Type: text/plain; charset="windows-1252"
Content-Transfer-Encoding: base64
$PlaintextPart
--9-1410065408-1410065408=:27514
Content-Type: text/html; charset="windows-1252"
Content-Transfer-Encoding: base64
$HTMLPart
--9-1410065408-1410065408=:27514--
AKAM;
echo 'Try 3: ';
echo mail('your@mail.com', 'Testmail', $Body, $Headers) ? 'WIN' : 'FAIL';
?>
المحلول
ربما يكون لديك عودة نقل وخط تغذية هناك. يستخدم Windows CR + LF إلى خطوط النهاية، ولكن يستخدم Linux تغذية خط وحدها.
لا تنتمي إلى StackOverflow