简体   繁体   English

PHP:对base64编码的IMAP主体进行解码

[英]PHP: Decoding of base64 encoded IMAP body

PHP -IMAP I have saved all imap mail to database and displaying them from database. PHP -IMAP我已经将所有imap邮件保存到数据库并从数据库显示它们。 My problem is that one mail is showing "Content-Transfer-Encoding: base64". 我的问题是,一封邮件显示“ Content-Transfer-Encoding:base64”。 If i base64 decode it then other mails also get affected. 如果我对base64进行解码,则其他邮件也会受到影响。 I haven't been able to change it to human readable format till yet. 到目前为止,我还无法将其更改为人类可读的格式。 Any help will be highly appreciated. 任何帮助将不胜感激。 I have tried many solution but The code currently I am using is, 我尝试了很多解决方案,但是当前使用的代码是

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

The output of this mail is 该邮件的输出为

------=_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--

它是base64,您必须在主体部分使用base64_decode,如下所示:

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

just to manually check there are several online services like http://www.motobit.com/util/base64-decoder-encoder.asp 只是为了手动检查,有一些在线服务,例如http://www.motobit.com/util/base64-decoder-encoder.asp

just copy and paste the base64 source and choose "decode". 只需复制并粘贴base64源,然后选择“解码”即可。 You will get a "human readyble format". 您将获得“人为就绪格式”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM