我有一个第三方程序,它基本上允许用户发送电子邮件,然后将其显示在系统中。但问题是它生成这样的输出:我只想获取这些数据并将其格式化为合适的格式。我想避免正则表达式。是否有任何选项或标准方法可以以更美观的方式显示以下内容。基本上我会将下面的所有内容关联为 $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--
PEAR::Mail_mimeDecode是一个很好的解码 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.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)