php mailparse 解析 .eml 文件
2014-07-28 16:06
543 查看
foreach ($filname as $k => $v) { $suffix = explode('.', $v); switch ($suffix[1]) { case 'eml': $mime = mailparse_msg_parse_file($this->save_path.'/'.$v); //mime 解析文件 $struct = mailparse_msg_get_structure($mime); //解析 结构 foreach ($struct as $k => $st) { $section = mailparse_msg_get_part($mime, $st); //解析 根据 id 获取part $info = mailparse_msg_get_part_data($section); // 获取 part 数据信息 array() if ($info['content-type'] == 'application/octet-stream' && $info['content-disposition'] == 'attachment') { $name = iconv('gbk', 'utf-8', $info['content-name']); $name_array = explode('.', $name); if (is_array($name_array)) { $name = urlencode($name_array[0]); ob_start(); // 打开缓冲区 mailparse_msg_extract_part_file($section, $this->save_path.'/'.$v); // 读取 制动part 内的数据 $contents = ob_get_contents(); //获取数据 ob_end_clean(); $file_hanle = fopen($this->save_path . '/' . $name . '.' . $name_array[1], 'w+'); fwrite($file_hanle, $contents); fclose($file_hanle); } } } //unlink($v); } }使用扩展 mailparse 注意安装
相关文章推荐
- PHP 解析Maildir 邮件格式(eml文件)
- PHP读取、解析eml文件及生成网页的方法示例
- PHP下解析swf文件头
- PHP - Manual手册 - XL. Filesystem 文件系统函数 - fgetcsv从文件指针中读入一行并解析 CSV 字段
- Nginx+PHP 配置漏洞:静态文件都可以当作 PHP 解析
- php解析excel文件
- php官方网---php解析xml文件
- 读取eml格式文件,并解析
- PHP-ExcelReader:用于解析excel文件的PHP类库
- PHP通过DOM解析XML文件或者xml字符串
- PHP用闭包思想写的torrent文件解析工具
- nginx php有关cgi.fix_pathinfo导致文件类型错误解析漏洞
- 关于iis解析php文件的方案
- php配置文件解析
- PHP通过eml邮件文件提取图片附件
- Nginx+PHP 配置漏洞:静态文件都可以当作 PHP 解析
- 使用PHP DOM-XML创建和解析XML文件
- eml文件的解析和发送 [三角猫]
- uchome二次开发 php程序讲解(common.php文件解析)
- PHP如何解析一个ini的配置文件?