0

PHP -IMAP I have saved all imap mail to database and displaying them from database. My problem is that one mail is showing "Content-Transfer-Encoding: base64". If i base64 decode it then other mails also get affected. 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--
Mayank Awasthi
  • 337
  • 3
  • 14
  • Maybe this post could help you: **http://stackoverflow.com/questions/15539902/php-imap-decoding-messages** – Kart Jan 22 '14 at 21:47

2 Answers2

0

It's base64, you have to use base64_decode on body part like this:

base64_decode('OTA5MTU5Mzg3DQoNCuS7juaKgOacr+i1sOWQkeeuoeeQhueahOWbm+S4quaguOW/gw0KMjAxMi05LTE1ICAxNjowMjoxNw==');
Night2
  • 1,168
  • 9
  • 18
  • yes i have used base64_decode(not base64 decode) but it still doesn't show the required result. Actually it shows some symbol. – Mayank Awasthi Sep 18 '12 at 11:20
  • This is the output of base64_decode 5m=MtNn=u?<{^^?rn{^j{z'rb?909159387 ???????????? 2012-9-15 16:02:17^?4NMv]*'O*^mfZ? z{S}?xj?= QeA!Q50AU 1%\Q!Q50?Q???84(!Q50!4(5Q???????? ??Q4(5Q9IQ=H?5M!Q50?!4( =d4(@=9P? H H;*r�BGBjno?=9P@4(@=9P???=9P@ =d!Q504(5m=MtNn=u? – Mayank Awasthi Sep 18 '12 at 11:21
  • This is what I'm getting by base64_decode, a number, a date and some Chinese words: `909159387 从技术走向管理的四个核心 2012-9-15 16:02:17` Translation of Chinese words is: `From the technical to the management of the four core` – Night2 Sep 18 '12 at 19:14
-4

just to manually check there are several online services like http://www.motobit.com/util/base64-decoder-encoder.asp

just copy and paste the base64 source and choose "decode". You will get a "human readyble format".

sladda
  • 332
  • 5
  • 12