php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9209 imap_fetchstructure doesnt return envelope of 'message/rfc822'-subparts
Submitted: 2001-02-10 20:49 UTC Modified: 2001-05-03 15:27 UTC
From: JoergLudwig at gmx dot de Assigned:
Status: Closed Package: IMAP related
PHP Version: 4.0.4 OS: SuSE Linux 7.0
Private report: No CVE-ID: None
 [2001-02-10 20:49 UTC] JoergLudwig at gmx dot de
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--

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-22 16:06 UTC] JoergLudwig at gmx dot de
From: Ryan Finnie [mailto:rfinnie@kefta.com]

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
 [2001-05-03 15:27 UTC] chagenbu@php.net
Ryan's comment describes the way to get at this info in c-client.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 09:01:26 2024 UTC