简体   繁体   English

mime_parser.php无法解码带有附件的电子邮件

[英]mime_parser.php not decoding emails with attachments

I have a script that is using cpanel pipe to execute a php file whenever a mail is received. 每当接收到邮件时,我都有一个使用cpanel管道执行php文件的脚本。 My problem is that whenever I send an email with attachments; 我的问题是,每当我发送带有附件的电子邮件时; the mime_parser.php library doesn't decode that information as well. mime_parser.php库也不会解码该信息。 Here is my code: 这是我的代码:

#!/usr/bin/php -q
<?php
  require_once('inc/engage.php');

  // Create socket
  $sock = fopen("php://stdin", 'r');
  $email = '';
  while(!feof($sock)){
   $email .= fread($sock, 1024);
  }

  fclose($sock);

  require_once('libraries/rfc822_addresses.php');
  require_once('libraries/mime_parser.php');

  $mime = new mime_parser_class;
  $mime->ignore_syntax_errors = 1;
  $parameters = array('Data' => $email);

  $mime->Decode($parameters, $decoded);

  $DB->query("INSERT INTO email_accounts_mail (`message`) VALUES('".serialize($decoded)."')");
?>

rfc822_addresses.php: https://raw.githubusercontent.com/suhastech/pushmail/master/class/rfc822_addresses.php rfc822_addresses.php: https ://raw.githubusercontent.com/suhastech/pushmail/master/class/rfc822_addresses.php

mime_parser.php: https://raw.githubusercontent.com/ryancramerdesign/EmailImage/master/pop3_classes/mime_parser.php mime_parser.php: https ://raw.githubusercontent.com/ryancramerdesign/EmailImage/master/pop3_classes/mime_parser.php

I want the email to decode the message with and without attachments. 我希望电子邮件对包含和不包含附件的邮件进行解码。 Now it decodes it without attachments; 现在,它无需附加附件即可解码; but not with... what am I missing? 但是没有...我想念什么?

I figured it out myself. 我自己弄清楚了。 By saving the data in a tmp folder and deleting it after it was used, I could retrieve all data stored by the attachments. 通过将数据保存在tmp文件夹中并在使用后将其删除,我可以检索附件存储的所有数据。 It was done by adding the SaveBody attribute in the parameters array with a specified folder (mine was tmp), and then creating the folder. 通过在带有指定文件夹(我的是tmp)的参数数组中添加SaveBody属性,然后创建该文件夹来完成。 After I'm done with the content within the folder I delete all files there to save up space. 完成文件夹中的内容之后,我删除了那里的所有文件以节省空间。 :-) :-)

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

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