0

Content タイプは message の一部として処理されますが、それを修正するにはどうすればよいですか? ありがとう

From - Wed Jun 05 12:29:59 2013
X-Account-Key: account1
X-UIDL: 50933ddb0000053d
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
X-Mozilla-Keys:                                                                                 
Return-Path: <flippingST@DPS_FDBD.localdomain>
Received: from xxxxxxxxx (SMTP1 [xxxxxxx])
    by xxxxxx (8.13.8/8.13.8) with ESMTP id r554TvMv018216
    for <leochan@pop.singtao.com>; Wed, 5 Jun 2013 12:29:57 +0800
Received: from cip.singtaonewscorp.com (cip.singtaonewscorp.com [202.66.86.162] (may be forged))
    by xxxxxxx  with Microsoft SMTPSVC(xxxxxxxxx);
    for <leo.chan@singtaonewscorp.com>; Wed, 5 Jun 2013 12:29:56 +0800
Date: Wed, 5 Jun 2013 12:29:56 +0800
From: flippingST@DPS_FDBD.localdomain
Message-Id: <201306050429.r554TudQ021830@smtp.singtao.com>
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AogdALq9rlEuic+b/2dsb2JhbABagzk0gkEBhw+jHgsBkhIdTBd0giMBFQE7AQo8FQEBVgcNEySIEQiPSYxDjgYBAYVBAZxtgj6BBwMEC50ji02DSw
X-IronPort-AV: E=Sophos;i="4.87,804,1363104000"; 
   d="scan'208,217";a="25969537"
Received: from ec2-46-137-207-155.ap-southeast-1.compute.amazonaws.com (HELO DPS_FDBD.localdomain) ([46.137.207.155])
  by cip.singtaonewscorp.com with ESMTP; 05 Jun 2013 12:30:48 +0800
Received: by DPS_FDBD.localdomain (Postfix, from userid 500)
    id D8FEE4329E; Wed,  5 Jun 2013 00:29:28 -0400 (EDT)
To: leo.chan@singtaonewscorp.com
Subject: =?UTF-8?B?5oql56ug5YaF5a655YiG5Lqr?=
X-PHP-Originating-Script: 500:mail.php
MIME-Version: 1.0
X-EsetId: 40C9373366470C695FCF37616E1C4038

Content-type: text/html; charset=UTF-8

From: leo.chan@singtaonewscorp.com  <leo.chan@singtaonewscorp.com>
Message-Id: <20130605042928.D8FEE4329E@DPS_FDBD.localdomain>
Date: Wed,  5 Jun 2013 00:29:28 -0400 (EDT)

<html><head></head><body><b>讯息 :</b>leo.chan@singtaonewscorp.com</br></br>分享连结 :</b><a href = "http://46.137.207.155/?product=ChangSha&issue=20130524&page=1">按此观看</a></br></br><img src = "https://s3-ap-southeast-1.amazonaws.com/demosource/ChangSha/2013/05/24/0/0/A/Content/1/Pg001.png" /></body></html>

__________ Information from ESET NOD32 Antivirus, version of virus signature database 8412 (20130604) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

上記はメールのソースコードです。

 Content type ,From: leo.chan@singtaonewscorp.com  <leo.chan@singtaonewscorp.com>
Message-Id: <20130605042928.D8FEE4329E@DPS_FDBD.localdomain>
Date: Wed,  5 Jun 2013 00:29:28 -0400 (EDT)

メールメッセージの一部です

ここに php コードがあります。コンテンツ タイプを header に設定しましたが、MIME バージョン 1.0 の後で切断されたようです。これを修正する方法は?ありがとう。

<?php
function encodeMIMEString ($enc, $string)
{
   return "=?$enc?B?".base64_encode($string)."?=";
}

if (isset($_POST["data"])){
    // Get posted data
    $mailStr = $_POST["data"];
    $mailStr = str_replace ('&page','#page',$mailStr);
    $mailStr = str_replace ('&issue','#issue',$mailStr);
    $info = explode("&", $mailStr);

    // To send HTML mail, the Content-type header must be set
    $headers  = "MIME-Version: 1.0\r\nContent-type: text/html; charset=UTF-8\r\n";
    $headers .= "From: $info[0] <$info[0]>";

    // Read XML to place the headings in mail content  
    $xml = simplexml_load_file('lang'.DIRECTORY_SEPARATOR.$info[4].'.xml') 
       or die("Error: Cannot create object");

    $subject = (string)$xml->mailTitle;
    $mailMsgDes = (string)$xml->mailMsgDes;
    $mailLink = (string)$xml->mailLink;
    $mailLinkView = (string)$xml->mailLinkView; 

    $message = nl2br(htmlentities(trim($info[2]), ENT_QUOTES, "UTF-8"));

    $url = str_replace ('#page','&page',$info[3]);
    $url = str_replace ('#issue','&issue',$url);

    $mailContent = '<html><head></head><body><b>'.$mailMsgDes.' :</b>'.$message.'</br></br>'.$mailLink.' :</b><a href = "'.$url.'">'.$mailLinkView.'</a></br>';

    if (isset($info[5])){
        $mailContent = $mailContent."</br><img src = \"$info[5]\" />";
    }
    if (isset($info[6])){
        $mailContent = $mailContent."</br><img src = \"$info[6]\" />";
    }

    $mailContent .= '</body></html>';

    if (mail($info[1], encodeMIMEString("UTF-8", $subject), $mailContent, $headers))
        echo 'Mail sent';
}
?>
4

3 に答える 3

1

FROM ヘッダーを MIME-Version と Content-type の定義の上に置きます。交換するだけです:

// To send HTML mail, the Content-type header must be set
$headers = "From: $info[0] <$info[0]>\r\n";
$headers .= "MIME-Version: 1.0\r\nContent-type: text/html; charset=UTF-8\r\n\r\n";
于 2013-06-05T04:37:43.080 に答える
0

PHP_EOL 定数を使用すると、\r、\n、または \r\n について心配する必要がなくなり、サーバー間でのコードの移植性が向上します。

于 2013-07-27T16:33:22.113 に答える