如何用php生成outlook msg文件

时间:2013-05-10 16:27:22

标签: php outlook

我正在尝试使用php生成msg文件。集管;

header("Pragma: public");
header("Expires: 0");
header('Content-Encoding: UTF-8');
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-type: application/vnd.ms-outlook;charset=UTF-8"); 
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");;
header("Content-Disposition: attachment;filename=test.msg");
header("Content-Transfer-Encoding: binary ");

但是我在打开时收到错误消息

文件内容:

Date: Fri, 10 May 2013 19:17:49 +0300
Return-Path: xxxx@domain.com
To: xxxx@domain.com
From: =?UTF-8?Q?T=C3=BCxxx_xxx?= <xxxx@domain.com>
Reply-To: =?UTF-8?Q?T=C3=BCxxx_xxx?= <xxxxx@domain.com>
Subject: =?UTF-8?B?ZmFsc2U=?=
Message-ID: <838dbc263c534dc099336c468b254365@example.com>
X-Priority: 3
X-Mailer: PHPMailer 5.2.2 (http://code.google.com/a/apache-extras.org/p/phpmailer/)
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="b1_838dbc263c534dc099336c468b254365"


--b1_838dbc263c534dc099336c468b254365
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

test

--b1_838dbc263c534dc099336c468b254365
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body rightmargin="0" leftmargin="0" bottommargin="0" topmargin="0" marginwidth="0" marginheight="0">
test
</body>
</html>

--b1_838dbc263c534dc099336c468b254365--

1 个答案:

答案 0 :(得分:1)

这不是MSG文件,这是一个EML(MIME)文件。 MSG文件是二进制文件 - 它是一个OLE存储(IStorage)文件。

您可以显式创建MSG文件(其格式已记录)或使用第三方库,例如Redemption(使用RDOSession。CreateMessageFromMsgFile)。