PEAR Mail_mimeDecode attachments problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Louis Aslett

    PEAR Mail_mimeDecode attachments problem

    Hi,

    I am extremely stuck trying to port a PHP app from one server to
    another while making use of the PEAR Mail_mimeDecode package. We have
    just upgraded from RedHat 7.x to RedHat Enterprise Linux ES Basic v3
    because of the end-of-life statement from RedHat. Basically, this
    means a change from Apache 1.3 to 2 and PHP 4.1.2 to 4.3.2.

    After initial problems getting Mail_mimeDecode to return any
    attachments to emails I downloaded and installed the latest version
    from pear.php.net. However, this still does not work and only returns
    the body in array element part[0], but nothing in part[1] as it used
    to. I tried wholesale copying the PEAR directory and a very simple
    test script to a RedHat 7.x server and everything works perfectly, but
    a perfect byte-for-byte replica on the RHEL3 server only returns the
    body.

    The test script is:



    #!/usr/bin/php -q
    <?
    require_once('/usr/share/php/Mail.php');
    require_once('/usr/share/php/Mail/mimeDecode.php' );

    $stdin = fopen('php://stdin','r');
    if( !$stdin ) {
    echo 'ERROR: Cannot open stdin';
    exit();
    }

    $msg = fread($stdin,10 00000);

    fclose($stdin);

    $params['include_bodies '] = TRUE;
    $params['decode_bodies'] = TRUE;
    $params['decode_headers '] = TRUE;
    $params['input'] = $msg;
    $params['crlf'] = "\n";
    $mail = Mail_mimeDecode ::decode($param s);

    print_r($mail);
    ?>



    and I pipe the email to it on the command line. On RHEL I get:



    [root@pe2500 smbtest]# cat test|./test.php
    stdClass Object
    (
    [headers] => Array
    (
    [from] => "HIDDEN" <HIDDEN@HIDDE N>
    [to] => <HIDDEN@HIDDE N>
    [subject] => HIDDEN
    [date] => Wed, 11 Feb 2004 09:11:43 -0000
    [mime-version] => 1.0
    [content-type] => multipart/mixed;
    boundary="----=_NextPart_000_ 136C_01C3F24A.3 AE231F0"
    [x-priority] => 3
    [x-msmail-priority] => Normal
    [x-mimeole] => Produced By Microsoft MimeOLE
    V6.00.2800.1165
    )

    [ctype_primary] => multipart
    [ctype_secondary] => mixed
    [ctype_parameter s] => Array
    (
    [boundary] => ----=_NextPart_000_ 136C_01C3F24A.3 AE231F0
    )

    [parts] => Array
    (
    [0] => stdClass Object
    (
    [headers] => Array
    (
    [content-type] => text/plain;
    charset="iso-8859-1"
    [content-transfer-encoding] => 7bit
    )

    [ctype_primary] => text
    [ctype_secondary] => plain
    [ctype_parameter s] => Array
    (
    [charset] => iso-8859-1
    )

    [body] => Lots of body content here

    )

    )

    )



    with no sign of any second MIME part, whereas I get



    [1] => stdClass Object
    (
    [headers] => Array
    (
    [content-type] => application/pdf;
    name="05041534. pdf"
    [content-transfer-encoding] => base64
    [content-disposition] => attachment;
    filename="05041 534.pdf"
    )

    [ctype_primary] => application
    [ctype_secondary] => pdf
    [ctype_parameter s] => Array
    (
    [name] => 05041534.pdf
    )

    [disposition] => attachment
    [d_parameters] => Array
    (
    [filename] => 05041534.pdf
    )

    [body] => %PDF-1.1
    3 0 obj
    <</Type /XObject
    /Subtype /Image
    etc etc etc



    following the first MIME part on the 7.x machine.

    I am completely dumbfounded. Are there *any* changes between PHP
    4.1.2 and 4.3.2 which break Mail_mimeDecode ?? I've tried looking
    through the source, but none of the functions jump out as having
    undergone any changes between those PHP versions.

    Many thanks in anticipation,

    Louis
  • Louis Aslett

    #2
    Re: PEAR Mail_mimeDecode attachments problem

    louis@6internet .com (Louis Aslett) wrote in message news:<88adeb46. 0402160931.4995 905d@posting.go ogle.com>...[color=blue]
    > Hi,
    >
    > I am extremely stuck trying to port a PHP app from one server to
    > another while making use of the PEAR Mail_mimeDecode package. We have
    > just upgraded from RedHat 7.x to RedHat Enterprise Linux ES Basic v3
    > because of the end-of-life statement from RedHat. Basically, this
    > means a change from Apache 1.3 to 2 and PHP 4.1.2 to 4.3.2.
    >
    > After initial problems getting Mail_mimeDecode to return any
    > attachments to emails I downloaded and installed the latest version
    > from pear.php.net. However, this still does not work and only returns
    > the body in array element part[0], but nothing in part[1] as it used
    > to. I tried wholesale copying the PEAR directory and a very simple
    > test script to a RedHat 7.x server and everything works perfectly, but
    > a perfect byte-for-byte replica on the RHEL3 server only returns the
    > body.
    >
    > The test script is:
    >[/color]
    [SNIP][color=blue]
    >
    > following the first MIME part on the 7.x machine.
    >
    > I am completely dumbfounded. Are there *any* changes between PHP
    > 4.1.2 and 4.3.2 which break Mail_mimeDecode ?? I've tried looking
    > through the source, but none of the functions jump out as having
    > undergone any changes between those PHP versions.
    >
    > Many thanks in anticipation,
    >
    > Louis[/color]

    For anyone interested, I've found that the problem is definitely
    PHP/PEAR related and not Red Hat Enterprise Linux. After much
    downloading/compiling of old PHP versions it transpires that the move
    from PHP 4.3.1 to 4.3.2 is where this functionality broke. Everything
    upto and including 4.3.1 work, but 4.3.2 and everything since don't.

    There is a new bug at http://pear.php.net/bugs/bug.php?id=779 which
    I've opened to report the issue.

    Louis

    Comment

    Working...