multipart/mixed mime attachments handling problem

Marek Tichy marek@gn.apc.org
Wed, 21 Nov 2001 21:03:11 -0000


Hi,
I've installed horde/imp/pop3 yesterday from cvs repository. It seems to be an excelent software, so many thanks indeed.

But I've soon got little bit confused about MIME attachment handling. I've used IMP compose message window to send myself simple
message with one .txt file attachment. You can see the message below - seems to be formatted correctly (sure, it was generated by
IMP itself). But as a result, I've got only

unnamed multipart/mixed 0.41 KB

line. It shows the whole message body. I briefly scanned imp mailinglist and found several complaints, but no solution. So I
debugged the code little bit. I'm not exactly sure where the problem is. As far as I understood, the *alternative* keyword is
somehow used to distinquish between multipart definitons and the actual attachment.
function _parse() from horde/lib/MIME/Structure.php seems to be responsible for assigning the proper values to this keyword. But as
you can see below in debug output, *alternative* values are empty strings for all three parts of the message (namely multipart mime
encapsulation, plaintext and text attachment).

As a workaroud, I've found the place where we take the decision what parts of the message display as attachments, according to
*alternative* value. It's in /hore/imp/message.php, line 150. Replacig original condition with far more stupid one

* $Horde: imp/message.php,v 2.259 2001/11/19 07:57:03 jan Exp $

//The old one:
//        if (!isset($displayParts[$mime->alternative]) || selectAlternativePart($mime,
//       $displayParts[$mime->alternative])) {
//The new one:
         if (($mime->TYPE ."/". $mime->subtype)!="multipart/mixed") {


gives me the desired results. But the question is - where is the problem ?  Is there any, or am I just dumb (misconfiguration
etc...)?

Best wishes
 Marek Tichy

PS: Details, for whom it might interest:

### Original message

From: marek@gn.apc.org
Message-ID: <1006366309.3bfbee650ccd7@setup.greennet.org.uk>
Date: Wed, 21 Nov 2001 18:11:49 +0000
To: marek@ecn.cz
Subject: zzz
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="-MOQ100636630973edb87898e70fb4a218085b0612d680"
User-Agent: Internet Messaging Program (IMP) 4.0-cvs
X-UIDL: 5fbc8711f7bb40487f4b9a421e2c0f30
Status: RO


This message is in MIME format.

---MOQ100636630973edb87898e70fb4a218085b0612d680
Content-Type: text/plain
Content-Transfer-Encoding: 7bit




---MOQ100636630973edb87898e70fb4a218085b0612d680
Content-Type: text/plain; name="attachtext.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="attachtext.txt"

MTEx

---MOQ100636630973edb87898e70fb4a218085b0612d680--




// debugging:
// $Horde: horde/lib/MIME/Structure.php,v 1.15 2001/08/28 16:27:02 chuck Exp $

//function _parse($body.......

// That's what the input is ($body value passed here by imap_fetchstructure()):
//============ $body start =======================================
object(stdClass)(11)

  ["type"]=> int(1)
  ["ifsubtype"]=> int(1)
  ["subtype"]=> string(5) "MIXED"
  ["ifdescription"]=> int(0)
  ["ifid"]=> int(0)
  ["bytes"]=> int(410)
  ["ifdisposition"]=> int(0)
  ["ifdparameters"]=> int(0)
  ["ifparameters"]=> int(1)
  ["parameters"]=> array(1) {
    [0]=> object(stdClass)(2)

      ["attribute"]=> string(8) "BOUNDARY"
      ["value"]=> string(46) "-MOQ100636630973edb87898e70fb4a218085b0612d680"
      }
    }
    ["parts"]=> array(2) {
      [0]=> object(stdClass)(10)

        ["ifsubtype"]=> int(1)
        ["subtype"]=> string(5) "PLAIN"
        ["ifdescription"]=> int(0)
        ["ifid"]=> int(0)
        ["lines"]=> int(2)
        ["bytes"]=> int(4)
        ["ifdisposition"]=> int(0)
        ["ifdparameters"]=> int(0)
        ["ifparameters"]=> int(1)
        ["parameters"]=> array(1)

          [0]=> object(stdClass)(2)

            ["attribute"]=> string(7) "CHARSET"
            ["value"]=> string(8) "US-ASCII"
            }
          }
        }
      [1]=> object(stdClass)(13) {
        ["encoding"]=> int(3)
        ["ifsubtype"]=> int(1)
        ["subtype"]=> string(5) "PLAIN"
        ["ifdescription"]=> int(0)
        ["ifid"]=> int(0)
        ["lines"]=> int(1)
        ["bytes"]=> int(6)
        ["ifdisposition"]=> int(1)
        ["disposition"]=> string(10) "ATTACHMENT"
        ["ifdparameters"]=> int(1)
        ["dparameters"]=> array(1)

          [0]=> object(stdClass)(2)

             ["attribute"]=> string(8) "FILENAME"
             ["value"]=> string(14) "attachtext.txt"
             }
          }
        ["ifparameters"]=> int(1)
        ["parameters"]=> array(1) {
          [0]=> object(stdClass)(2) {
            ["attribute"]=> string(4) "NAME"
            ["value"]=> string(14) "attachtext.txt"
            }
          }
        }
      }
    }
//============= end ==================================

// Thats what the function gives as a result ($attachments)
//============ return start ===================================
array(3) {
 [""]=> object(stdClass)(17) {
    ["ref"]=> string(0) ""
    ["type"]=> int(1)
    ["subtype"]=> string(5) "mixed"
    ["encoding"]=> int(0)
    ["charset"]=> string(8) "us-ascii"
    ["bytes"]=> int(410)
    ["size"]=> string(4) "0.40"
    ["disposition"]=> string(6) "inline"
    ["id"]=> bool(false)
    ["boundary"]=> string(46) "-MOQ100636630973edb87898e70fb4a218085b0612d680"
    ["description"]=> string(7) "unnamed"
    ["name"]=> string(7) "unnamed"
    ["TYPE"]=> string(9) "multipart"
    ["alternative"]=> string(0) ""
    ["header"]=> bool(false)
    ["imap_id"]=> string(0) ""
    ["index"]=> string(1) "1"
    }
 [1]=> object(stdClass)(16) {
    ["ref"]=> string(1) "1"
    ["type"]=> int(0)
    ["subtype"]=> string(5) "plain"
    ["encoding"]=> int(0)
    ["charset"]=> string(8) "US-ASCII"
    ["bytes"]=> int(4)
    ["size"]=> string(4) "0.00"
    ["disposition"]=> string(6) "inline"
    ["id"]=> bool(false)
    ["description"]=> string(7) "unnamed"
    ["name"]=> string(7) "unnamed"
    ["TYPE"]=> string(4) "text"
    ["alternative"]=> string(0) ""
    ["header"]=> bool(false)
    ["imap_id"]=> string(1) "1"
    ["index"]=> string(1) "1"
    }
 [2]=> object(stdClass)(17)

    ["ref"]=> string(1) "2"
    ["type"]=> int(0)
    ["subtype"]=> string(5) "plain"
    ["encoding"]=> int(3)
    ["charset"]=> string(8) "us-ascii"
    ["bytes"]=> int(6)
    ["size"]=> string(4) "0.01"
    ["disposition"]=> string(10) "attachment"
    ["id"]=> bool(false)
    ["name"]=> string(14) "attachtext.txt"
    ["filename"]=> string(14) "attachtext.txt"
    ["description"]=> string(14) "attachtext.txt"
    ["TYPE"]=> string(4) "text"
    ["alternative"]=> string(0) ""
    ["header"]=> bool(false)
    ["imap_id"]=> string(1) "2"
    ["index"]=> string(1) "1"
    }
 }
//============ end ============================================


>List:     imp
>Subject:  Re: [imp] Attachment problem still...
>From:     Chuck Hagenbuch <chuck@horde.org>
>Date:     2001-09-06 23:35:51
>[Download message RAW]
>
>Quoting Dave Brancato <g00ru@cyberedge.net>:
>
>> When I attach a word document IMP is still recoginzing as >"unnamed
>> multipart/mixed". When I goto save the message it saves it as unamed. Any
>> idea how to fix?

>Well, then that's what the browser and webserver are telling IMP it is. Nothing
>IMP can change about that...
>
>-chuck
>
>--
>Charles Hagenbuch, <chuck@horde.org>
>Some fallen angels have their good reasons.