PHP IMAP获取签名附件

PHP IMAP获取签名附件,php,imap,Php,Imap,我用PHP-IMAP解析电子邮件时遇到问题。问题是我的邮件是用pkcs#7签名的。邮件包含一些文本和两个附件,第一个是smime.p7s,第二个是message.htm,这是我要解析的html附件 老实说,我不知道如何访问此文件的内容 $hostname = '{host}INBOX'; $username = 'name'; $password = 'pass'; /* try to connect */ $inbox = imap_open($host

我用
PHP-IMAP
解析电子邮件时遇到问题。问题是我的邮件是用pkcs#7签名的。邮件包含一些文本和两个附件,第一个是
smime.p7s
,第二个是
message.htm
,这是我要解析的
html
附件

老实说,我不知道如何访问此文件的内容

    $hostname = '{host}INBOX';
    $username = 'name';
    $password = 'pass';
    /* try to connect */
    $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
    /* grab emails */
    $emails = imap_search($inbox,'UNSEEN');
    $msg = Array();
    if($emails) {
        /* begin output var */
        $output = '';

        /* put the newest emails on top */
        rsort($emails);
        /* for every email... */
        foreach($emails as $email_number) {
            $overview = imap_fetch_overview($inbox,$email_number,0);
            $message = imap_fetchbody($inbox,$email_number,2);
            $structure = imap_fetchstructure ( $inbox,$email_number,FT_UID);
            echo "<pre>";
            var_dump($structure);
            echo "</pre>";
            break;
        }
    }

有人能告诉我如何访问
message.htm
的内容吗?

由于结构没有定义任何
部分,因此消息是“简单的”

尝试使用:

这将获取消息的“0”部分,该部分应为正文


查看这里的文档:

您在
var\u dump($message)
之后是否尝试过
var\u dump($structure)
?是的,我得到了一些
base64
编码字符串解码后,我得到了一些用
VeriSign
证书编码的随机符号我猜我想用
imap\u-fetchbody(…)替换
imap\u-body(…)
Hmm我想我得到了一些我能够实际解析的东西(ofc它包含某种
消息。hml
       object(stdClass)#16 (14) {
          ["type"]=>
          int(0)
          ["encoding"]=>
          int(4)
          ["ifsubtype"]=>
          int(1)
          ["subtype"]=>
          string(4) "HTML"
          ["ifdescription"]=>
          int(0)
          ["ifid"]=>
          int(0)
          ["lines"]=>
          int(123)
          ["bytes"]=>
          int(4473)
          ["ifdisposition"]=>
          int(1)
          ["disposition"]=>
          string(10) "attachment"
          ["ifdparameters"]=>
          int(1)
          ["dparameters"]=>
          array(1) {
            [0]=>
            object(stdClass)#17 (2) {
              ["attribute"]=>
              string(8) "filename"
              ["value"]=>
              string(37) "message.htm"
            }
          }
          ["ifparameters"]=>
          int(1)
          ["parameters"]=>
          array(2) {
            [0]=>
            object(stdClass)#18 (2) {
              ["attribute"]=>
              string(4) "name"
              ["value"]=>
              string(37) "message.htm"
            }
            [1]=>
            object(stdClass)#19 (2) {
              ["attribute"]=>
              string(7) "charset"
              ["value"]=>
              string(8) "us-ascii"
            }
          }
        }
$message = imap_fetchbody($inbox,$email_number,0);