ID: 9209
User Update by: [EMAIL PROTECTED]
Status: Open
Bug Type: IMAP related
Description: imap_fetchstructure doesnt return envelope of 'message/rfc822'-subparts

From: Ryan Finnie [mailto:[EMAIL PROTECTED]]

I saw your bug report on bugs.php.net -- pity a 3rd party can't add comments or I 
would have posted that there.

Anyways, php uses the c-client library, which can be broken in some aspects.  To get 
information about the envelope, you would need to do 
imap_rfc822_parse_headers(imap_fetchbody($mbox, $msgid, "$part.0"));

In your example in the bug, $part would be "2".  This will return an object similar to 
imap_headerinfo (IE, grabbing the envelope from the main message).  Technically, 
according to the RFC, you should grab $part.HEADER, not $part.0 -- but like I said, 
c-client is a bit screwy.  I left an explanation of that part of the problem in
http://php.net/manual/en/function.imap-fetchbody.php

Please let me know if this helps.
Ryan Finnie

Previous Comments:
---------------------------------------------------------------------------

[2001-02-10 20:49:04] [EMAIL PROTECTED]
When i connect directly via telnet to my IMAP-Server, 'fetch n (bodystructure)' 
returns the envelope of subparts with the type 'message/rfc822', as described in RFC 
2060. (I do not mean the envelope of the main-part!)

But when i call imap_fetchstructure via PHP, i do NOT get any envelope?!

Is there any other way to get these envelopes? Now i have to download the whole 
message and parse it myself. But this of course is very slow in PHP ;)

--- IMAP-Server Reply ---
BODYSTRUCTURE
(
  (
    "TEXT" "PLAIN" ("CHARSET" "iso-8859-1")
    NIL NIL "7BIT" 9 1 NIL NIL NIL
  )
  (
    "MESSAGE" "RFC822" ("NAME" "Submail.eml")
    NIL NIL "7BIT" 335
    (
      "Sun, 11 Feb 2001 02:28:41 +0100"
      "Submail"
      (("Tester" NIL "Tester" "host"))
      (("Tester" NIL "Tester" "host"))
      (("Tester" NIL "Tester" "host"))
      ((NIL NIL "Test" ".MISSING-HOST-NAME."))
      NIL NIL NIL NIL
    )
    (
      "TEXT" "PLAIN" ("CHARSET" "iso-8859-1")
      NIL NIL "7BIT" 9 1 NIL NIL NIL
    )
    13 NIL ("ATTACHMENT" ("FILENAME" "Submail.eml")) NIL
  )
  "MIXED" ("BOUNDARY" "----123") NIL NIL
)

--- PHP imap_fetchstructure Result (shortened) ---
obj [
  "type" = 1
  "subtype" = "MIXED"
  "parameters" = arr {
    0 = obj ["attribute" = "BOUNDARY" "value" = "----123"]
  }
  "parts" = arr {
    0 = obj [
      "subtype" = "PLAIN"
      "lines" = 1
      "bytes" = 9
      "parameters" = arr {
        0 = obj ["attribute" = "CHARSET" "value" = "iso-8859-1"]
      }
    ]
    1 = obj [
      "type" = 2
      "subtype" = "RFC822"
      "lines" = 13
      "bytes" = 335
      "disposition" = "ATTACHMENT"
      "dparameters" = arr {
        0 = obj ["attribute" = "FILENAME" "value" = "Submail.eml"]
      }
      "parameters" = arr {
        0 = obj ["attribute" = "NAME" "value" = "Submail.eml"]
      }
      "parts" = arr {
        0 = obj [
          "subtype" = "PLAIN"
          "lines" = 1
          "bytes" = 9
          "parameters" = arr {
            0 = obj ["attribute" = "CHARSET" "value" = "iso-8859-1"]
          }
        ]
      }
    ]
  }
]

--- Mail Sourcecode (shortened) ---
From: "Tester" <Tester@host>
To: "Someone"
Subject: Mailmail
Date: Sun, 11 Feb 2001 02:29:12 +0100
Content-Type: multipart/mixed;
        boundary="----123"

This is a multi-part message in MIME format.

----123
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Content

----123
Content-Type: message/rfc822; name="Submail.eml"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="Submail.eml"

From: "Tester" <Tester@host>
To: "Test"
Subject: Submail
Date: Sun, 11 Feb 2001 02:28:41 +0100
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Content

----123--


---------------------------------------------------------------------------


Full Bug description available at: http://bugs.php.net/?id=9209


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to