Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我能';我没有收到电子邮件的附件_Php_Excel_Imap - Fatal编程技术网

Php 我能';我没有收到电子邮件的附件

Php 我能';我没有收到电子邮件的附件,php,excel,imap,Php,Excel,Imap,我有一个连接到imap并获取excel文件的脚本。到今天为止,它工作得很好。对于我们的一个供应商,脚本无法获取附加文件。我认为解码电子邮件有问题 这是解码的代码 if($attachments[$i]['is_attachment']) { $attachments[$i]['attachment'] = imap_fetchbody($this->_mbox,$email_number,$i); /* 4 = QUOTED-PRINTABLE encoding */ i

我有一个连接到imap并获取excel文件的脚本。到今天为止,它工作得很好。对于我们的一个供应商,脚本无法获取附加文件。我认为解码电子邮件有问题

这是解码的代码

 if($attachments[$i]['is_attachment'])
 {
    $attachments[$i]['attachment'] = imap_fetchbody($this->_mbox,$email_number,$i);
/* 4 = QUOTED-PRINTABLE encoding */
   if($flattenedParts[$i]->encoding == 3)
   {
       $attachments[$i]['attachment'] = base64_decode($attachments[$i]['attachment']);
   }
   elseif($flattenedParts[$i]->encoding == 4)/* 3 = BASE64 encoding */
   {
       $attachments[$i]['attachment'] = quoted_printable_decode($attachments[$i]['attachment']);
   }
 }
在php上使用imap解码电子邮件还有其他方法吗

imap的数组

Array
(
[1] => stdClass Object
    (
        [type] => 0
        [encoding] => 0
        [ifsubtype] => 1
        [subtype] => PLAIN
        [ifdescription] => 0
        [ifid] => 0
        [lines] => 38
        [bytes] => 431
        [ifdisposition] => 0
        [ifdparameters] => 0
        [ifparameters] => 1
        [parameters] => Array
            (
                [0] => stdClass Object
                    (
                        [attribute] => charset
                        [value] => us-ascii
                    )

            )

    )

[2] => stdClass Object
    (
        [type] => 3
        [encoding] => 3
        [ifsubtype] => 1
        [subtype] => MS-TNEF
        [ifdescription] => 0
        [ifid] => 0
        [bytes] => 3584988
        [ifdisposition] => 1
        [disposition] => attachment
        [ifdparameters] => 1
        [dparameters] => Array
            (
                [0] => stdClass Object
                    (
                        [attribute] => filename
                        [value] => winmail.dat
                    )

            )

        [ifparameters] => 1
        [parameters] => Array
            (
                [0] => stdClass Object
                    (
                        [attribute] => name
                        [value] => winmail.dat
                    )

            )

    )

)

如果该脚本在今天仍然运行良好,则表示您的提供商更改了邮件配置中的某些内容,从而使其崩溃。问他们那是什么。他把Excel文件从.xls改为.xlsx。但是有许多其他供应商也会发送.xlsx文件,这没有问题,但我不知道他为什么不能获得文件。你检查了
编码的值了吗?如果既不是3也不是4,则附件将不会被解码。
[subtype]=>MS-TNEF
->