简体   繁体   English

imap主体的Base64编码不起作用

[英]Base64 encoding of imap body not working

I have looked all over the place for the past couple of days and still cant find the answer. 在过去的几天里,我到处都在寻找,仍然找不到答案。 I have an imap php app that fetches emails from my outlook account, all works perfect and the messages are displayed nice but im having an issue with a couple of emails, bodytype returns as base64 but it doesnt encode properly (only on a couple, all other base64 get nicely decoded). 我有一个imap php应用程序,该程序可以从我的Outlook帐户中获取电子邮件,所有程序都可以正常工作,并且消息显示效果很好,但即时通讯中有几封电子邮件存在问题,bodytype返回为base64,但编码不正确(仅适用于一对夫妇,全部其他base64得到很好的解码)。 but this one before decoding is... 但是这个解码之前是...

/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIf IiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/wAALCAB4AHgBAREA/8QAHwAAAQUBAQEB AQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1Fh ByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZ WmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXG x8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/9oACAEBAAA/APZqKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK/9k=

and after decoding its even more gibberish that it stared off with instead of any meaningful text. 并且在解码后出现了更多乱码,因此开始盯着而不是任何有意义的文字。 What is this and how do i decode it properly ?? 这是什么,我如何正确解码? had a look at online decoders and all say its invalid 看了在线解码器,都说它无效

heres an image of what the email looks like in outlook 这是电子邮件在Outlook中的外观图像

在此处输入图片说明

Demo:: http://phpfiddle.org/main/code/876m-khae 演示:: http://phpfiddle.org/main/code/876m-khae

Reference: http://php.net/manual/en/function.imagecreatefromstring.php 参考: http : //php.net/manual/en/function.imagecreatefromstring.php

View Online Tools Decode Here: https://www.base64decode.org/ 在此处查看在线工具解码: https//www.base64decode.org/

<?php

$base64_string ="/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIf IiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/wAALCAB4AHgBAREA/8QAHwAAAQUBAQEB AQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1Fh ByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZ WmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXG x8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/9oACAEBAAA/APZqKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK/9k=
";

$decode_data = base64_decode($base64_string);

$image_create = imagecreatefromstring($decode_data);
if ($image_create !== false) {
    header('Content-Type: image/png');
    imagepng($image_create);
    imagedestroy($image_create);
}
else {
    echo 'An error occurred.';
}
?> 

NOTE:: You Can Also Use the base64ToImage funtion to decode this 注意::您还可以使用base64ToImage函数对此进行解码

Example: 例:

<?php

function base64ToImage($base64_string, $output_file) {

     $file = fopen($output_file, "wb");

     $data = explode(',', $base64_string);

     fwrite($file, base64_decode($data[1]));
     fclose($file);

     return $output_file;
}


?>

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

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