【问题标题】:Weird problem with PHP mail() under LinuxLinux下PHP mail()的奇怪问题
【发布时间】:2010-10-08 10:30:46
【问题描述】:

当它“在我的机器上工作”时就是这种情况。除了我的机器是 Windows,目标是某种 Linux。

这个想法是mail() 函数在MIME-VersionContent-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';
?>

【问题讨论】:

    标签: php email mime


    【解决方案1】:

    你可能有一个回车和一个换行。 Windows 使用 CR+LF 结束行,但 Linux 仅使用换行符。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-21
      • 2020-07-28
      • 2015-12-20
      • 2012-02-02
      • 2011-12-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多