douling8772 2012-03-28 13:09
浏览 48
已采纳

too long

I'm trying to make a ticketing system, but there are a few ways of doing it.

Piping

The problem with piping is trying to parse attachments and save them to a folder.

Here is a small script that I made

#!/usr/bin/php -q
<?php

//The concern here is having enough mem for emails with attachments.
ini_set('memory_limit', '256M'); 

ini_set("display_errors", "1");
error_reporting(E_ALL);

$data = isset($_SERVER['HTTP_HOST'])?file_get_contents('php://input'):file_get_contents('php://stdin');

$fdw = fopen("mail.txt", "w+");
fwrite($fdw, $data);
fclose($fdw);

?>

By using cPanel`s pipe to program.

It generates a raw email string, which contains alot of things that I don't understand. For example:

--_1f366895-b327-4f84-8985-e3826cdf604b_ Content-Type: application/octet-stream Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="something.zip" UEsFBBQACAAIAJuy1DgAAAAAAAAAAAAAAAAKAAAAcmVwb3J0LnhtbNVdW5fbNpJ+n1/B9Z6zb8Mh rgTPJplGt9N2HNvxiTPjM/vGltjdinUbUrLT+fVLUqJEUKSAYoE0p+10YkIdfwCBQl2+qvru73+s lt6XJM0Dm/X3z4gfPPOyXbyex8vNOvn+2VOSPfv7D3/5y3dpst2kux++28V3y+SH72ab5X61zqr/ 8NbxKv/0PN4Dz3747m+Hh43BWbzaxouHdecH4vlDutlvO8c/J09fN+m8e/zryyTb/SNddn5isdpm

Is there a way to parse them (img,docs,zip or etc) or put them in a folder/something.ext?

Is there another way to do this?

External services?

Is there already some service doing this?

  • 写回答

1条回答 默认 最新

  • douzhang3898 2012-03-28 13:11
    关注

    First get your output after the filename and then you decode your content with base64, because as you see in the header: Content-Transfer-Encoding: base64:

    file_put_contents('something.zip', base64_decode($output));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题