How to get rid of error messages using PHP imap_fetchstructure ()?

PHP provides very useful features for retrieving email from a POP3 account, in my case for processing scanned emails. However, the imap_fetchstructure () function gives me a headache. When you use it in one script, I (for some emails) get a message:

Note: Unknown: Warning: The MIME header appears in a message other than MIME (errflg = 3) in Unknown on line 0

The error reported by PHP was set to Bugus ( http://bugs.php.net/bug.php?id=43471 ), but I can not find the key to this problem in the documentation.

Nothing puts @ in front of the function and does not change the error handler before the function (and resetting it after that) helps. Disabling the error message or constantly changing the error handler or the help about the level of error messages (it seems that the error is running in the script too), however I need to register other errors that may occur after using this function.

So I'm looking for a hint in Stackoverflow: what exactly does this function mourn (I assume that the header or MIME content is with the wrong expression) and how can I get rid of this error notification?

+3
source share
2 answers

, , imap_close(), , script. imap_errors() ( ).

$struct = imap_fetchstructure($imap, $num);
$errs = imap_errors();
imap_close($imap);
+9

php, , @ . . !

php imap_fetchstructure() ext/imap/php_imap.c, mail_fetchstructure_full(), c-client.

c-client/rfc822.c :

  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-.

edit MM_LOG mm_log, , php/ext/imap/php_imap.c. imap_fetchstructure() ( !), , imap_errors(). , .

+3

Source: https://habr.com/ru/post/1757465/


All Articles