代码之家  ›  专栏  ›  技术社区  ›  BurninLeo

如何使用PHP的imap\u fetchstructure()清除错误消息?

  •  3
  • BurninLeo  · 技术社区  · 14 年前

    注意:未知:警告:MIME头 在非MIME消息中遇到

    向PHP报告的一个Bug被设置为status Bugus( http://bugs.php.net/bug.php?id=43471 ),但我在文档中找不到关于这个问题的线索。

    2 回复  |  直到 12 年前
        1
  •  11
  •   GZipp    14 年前

    我相信你打电话时会发出错误信息 imap_close() ,或者,在该函数不存在的情况下,当脚本结束时。试着打电话 imap_errors() 在此之前(清除错误堆栈)。

    $struct = imap_fetchstructure($imap, $num);
    $errs = imap_errors();
    imap_close($imap);
    
        2
  •  3
  •   mvds    14 年前

    这个错误不是由php发出的,这可能就是@不起作用的原因。 请看下面!

    imap_fetchstructure() 在ext/imap/php\u imap.c中,它是 mail_fetchstructure_full() ,它是c-client库的一部分。

      case 'C':                 /* possible cc: or Content-<mumble>*/
        if (!strcmp (tmp+1,"C")) rfc822_parse_adrlist (&env->cc,d,host);
        else if ((tmp[1] == 'O') && (tmp[2] == 'N') && (tmp[3] == 'T') &&
                 (tmp[4] == 'E') && (tmp[5] == 'N') && (tmp[6] == 'T') &&
                 (tmp[7] == '-') && body)
          switch (MIMEp) {
          case -1:              /* unknown if MIME or not */
            if (!(MIMEp =       /* see if MIME-Version header exists */
                  search ((unsigned char *) s-1,i,
                          (unsigned char *)"\012MIME-Version",(long) 13))) {
    #if 1
             /* This is a disgusting kludge, and most of the messages which
               * benefit from it are spam.
               */
              if (!strcmp (tmp+8,"TRANSFER-ENCODING") ||
                  (!strcmp (tmp+8,"TYPE") && strchr (d,'/'))) {
                MM_LOG ("Warning: MIME header encountered in non-MIME message",
                        PARSE);
                MIMEp = 1;      /* declare MIME now */
              }
              else
    #endif
    

    这是唯一一个产生错误的地方,根据 grep . 所以这就解释了我认为的大多数谜团。

    因此,您有一个带有CONTENT-TRANSFER-ENCODING或CONTENT-TYPE行的消息,没有MIME版本头。

    编辑 MM\u LOG被定义为MM\u LOG,而MM\u LOG又是php/ext/imap/php\u imap.c提供的函数。imap\u fetchstructure()中的错误被放在错误列表中(它们不是直接输出的!)你可能会问 而且是空的 使用 imap_errors()