PHP:解码base64编码的IMAP主体

时间:2012-09-18 11:10:50

标签: php imap decoding

PHP -IMAP 我已将所有imap邮件保存到数据库并从数据库中显示它们。我的问题是一封邮件显示“Content-Transfer-Encoding:base64”。如果我对它进行base64解码,那么其他邮件也会受到影响。到目前为止,我还无法将其更改为人类可读的格式。任何帮助将受到高度赞赏。 我尝试了很多解决方案,但目前我正在使用的代码是,

mb_convert_encoding($body, "ISO-8859-1", "UTF-8");

此邮件的输出是

------=_NextPart_001_0606_012497BF.12408D60
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: base64

 OTA5MTU5Mzg3DQoNCuS7juaKgOacr+i1sOWQkeeuoeeQhueahOWbm+S4quaguOW/gw0KMjAxMi05
 LTE1ICAxNjowMjoxNw==

 ------=_NextPart_001_0606_012497BF.12408D60
 Content-Type: text/html;
charset="utf-8"
 Content-Transfer-Encoding: base64

 PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwv
 L0VOIj4NCjxIVE1MPjxIRUFEPg0KPE1FVEEgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PXV0
 Zi04IiBodHRwLWVxdWl2PUNvbnRlbnQtVHlwZT4NCjxNRVRBIG5hbWU9R0VORVJBVE9SIGNvbnRl
 bnQ9Ik1TSFRNTCA4LjAwLjYwMDEuMTg5OTkiPjwvSEVBRD4NCjxCT0RZPg0KPFA+PEZPTlQgc2l6
 ZT0yPjkwOTE1OTM4NzxCUj48QlI+5LuO5oqA5pyv6LWw5ZCR566h55CG55qE5Zub5Liq5qC45b+D
 PC9GT05UPjwvUD4NCjxQPjxGT05UIHNpemU9Mj4yMDEyLTktMTUmbmJzcDsgMTY6MDI6MTc8L0ZP
 TlQ+PC9QPjwvQk9EWT48L0hUTUw+DQo=

 ------=_NextPart_001_0606_012497BF.12408D60--

2 个答案:

答案 0 :(得分:0)

它是base64,你必须在身体部位使用base64_decode:

base64_decode('OTA5MTU5Mzg3DQoNCuS7juaKgOacr+i1sOWQkeeuoeeQhueahOWbm+S4quaguOW/gw0KMjAxMi05LTE1ICAxNjowMjoxNw==');

答案 1 :(得分:-3)

只是手动检查有几个在线服务 http://www.motobit.com/util/base64-decoder-encoder.asp

只需复制并粘贴base64源代码并选择“解码”即可。你会得到一个“人性化的格式”。