SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    Melbourne
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Decoding mail using Mail_mimeDecode in PHP5

    Hi

    Has anyone ran into this error: Fatal error: Using $this when not in object context

    using PHP5 and Mail_mimeDecode (PEAR)?

    http://www.theukwebdesigncompany.com...ode-module.php

    Am running PHP5.0.2 running on a windows XP box.

    I've setup the test email message as:

    PHP Code:
    $input "Return-Path: <gvtulder@example.com> 
    Delivered-To: gijs@localhost 
    Received: (qmail 4400 invoked from network); 6 Mar 2003 18:13:52 -0000 
    Received: from unknown (HELO localhost) (gijs@127.0.0.1) 
      by localhost with SMTP; 6 Mar 2003 18:13:52 -0000 
    X-Flags: 0000 
    Delivered-To: GMX delivery to gvtulder@example.com 
    <!-- snip snip -->" 

    $params['include_bodies'] = true
    $params['decode_bodies'] = true
    $params['decode_headers'] = true
    $params['input'] = $input

    // do the decode 
    $structure Mail_mimeDecode::decode($params); 

    // save the attachment as a file. 
    foreach ($structure->parts as $part) { 
        
    // only save if an attachment 
        
    if (isset($part->disposition) and ($part->disposition=='attachment')) { 
            
    // open file 
            
    $fp fopen($part->ctype_parameters['filename'], 'w'); 
            
    // write body 
            
    fwrite($fp$part->body); 
            
    // close file 
            
    fclose($fp); 
        } 


    I've included the correct PEAR file..and all quotation marks are escaped properly in the $input. However I get the following message:

    Fatal error: Using $this when not in object context in c:\php5\PEAR\Mail\mimeDecode.php on line 168

    Is this PHP5 being buggy? I need to run in 5 as I'm using simpleXML. In the bigger picture all I want to decode is XML attached files.

    Kind Regards

    Dave.

    PS I posted a similar message yesterday in the ../PHP forum with not much luck.. am trying here again if that is ok!

  2. #2
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    Mail_mimeDecode::decode($params); 
    is calling the method statically. When you do this, there will be no $this variable.
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    Melbourne
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks sweatje

    Ok....do you see a workaround for this issue, without taking apart the class and rewriting?

    Kind regards

    Dave.

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    Melbourne
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Problem solved with a wee bit of hard work (and reading the manual <grin>!):

    PHP Code:
    $decoder = new Mail_mimeDecode($input);
    $structure $decoder->decode($params); 
    Cheers

    Dave.

  5. #5
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just what I was going to suggest (without reading the fine manual )

  6. #6
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    Melbourne
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the example given in the code the

    $part->ctype_parameters

    doesn't work...

    d_parameters does.

    Dave.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •