使用PHP读取MIME数据

使用PHP读取MIME数据,php,regex,email,Php,Regex,Email,我有一个第三方程序,基本上允许用户发送电子邮件,然后在系统中显示。但问题是,它生成的输出是这样的:我只想获取这些数据,并将其格式化为可呈现的格式。我想避免使用正则表达式。是否有任何选项或标准方式可以更形象地显示以下内容。基本上,我会将下面的所有内容关联为$text,然后调用一个函数clean($text)排序 > This message is in MIME format. Since your mail reader does not understand this format, s

我有一个第三方程序,基本上允许用户发送电子邮件,然后在系统中显示。但问题是,它生成的输出是这样的:我只想获取这些数据,并将其格式化为可呈现的格式。我想避免使用正则表达式。是否有任何选项或标准方式可以更形象地显示以下内容。基本上,我会将下面的所有内容关联为$text,然后调用一个函数clean($text)排序

> This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

--B_3331365494_4098727
Content-type: text/plain;
charset="US-ASCII"
Content-transfer-encoding: 7bit

test

--B_3331365494_4098727
Content-type: text/html;
charset="US-ASCII"
Content-transfer-encoding: quoted-printable

<HTML>
<HEAD>
<TITLE>Test</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>test</SPAN></FONT>
</BODY>
</HTML>


--B_3331365494_4098727--
>此消息采用MIME格式。因为你的邮件阅读器不明白
在这种格式下,此消息的部分或全部可能不清晰。
--B_3331365494_4098727
内容类型:文本/纯文本;
charset=“US-ASCII”
内容传输编码:7bit
测试
--B_3331365494_4098727
内容类型:text/html;
charset=“US-ASCII”
内容传输编码:引用可打印
试验
测试
--B_3331365494_4098727--
是解码MIME消息的好类。一旦安装,您就可以这样使用它:

$message = new Mail_mimeDecode($text);

$params['include_bodies'] = true;
$params['decode_bodies']  = true;
$params['decode_headers'] = true;

$messageStruct = $message->decode($params);
//messageStruct is now an array representing the message
// with all the parts properly included.

我可以包含任何直接php文件来代替安装此文件吗?使用下载>手动安装下载
Mail\u Mime
Mail\u mimeDecode
。将两者都提取出来,更正包含的内容,然后您就可以开始了!