www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] Error trying to decode an email part reterieved from imap_fetchbody()

  1. #1
    Join Date
    Dec 2013
    Location
    Melbourne, Australia
    Posts
    26

    resolved [RESOLVED] Error trying to decode an email part reterieved from imap_fetchbody()

    I have a process which has been checking an imap server for messages and the processing the emails if found.

    The process looks for a HTML attachment and then processes the file, stripping out the data and inserting into a database.

    This has been working fine up until now where it looks like the attachment has a different encoding than it previously did and is now calling a different function which is failing with this error:

    Code:
    Fatal error: Call to undefined function imap_7bit()
    I am using the code below which I found on the php.net website on the PHP documentation page for imap_fetchbody.

    I believe it is related to my version of PHP installed on my server and the additional modules I do or do not have.

    I'm looking for an alternative if I can't use this:

    PHP Code:
            //If we have an attachment and it is HTML let's continue
            
    if ($partObject->ifdisposition == && $partObject->subtype == 'HTML') {
                
                
    // fetch data from email part 
                
    $data imap_fetchbody($this->mbox,$mid,$partno);
                
                switch (
    $partObject->encoding) {
                    case 
    0:
                        
    $data imap_7bit($data);
                    case 
    1:
                        
    $data imap_8bit($data);
                    case 
    2:
                        
    $data imap_binary($data);
                    case 
    3:
                        
    $data imap_base64($data);
                    case 
    4:
                        
    $data quoted_printable_decode($data);
                    case 
    5:
                        
    $data $data;
                } 

  2. #2
    Join Date
    Feb 2014
    Location
    Viet Nam
    Posts
    33
    you can do this:
    - check method of object
    - check your PHP version, it supports or not

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,530
    I only see imap_8bit() as one of the IMAP functions in PHP.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Dec 2013
    Location
    Melbourne, Australia
    Posts
    26
    Thanks NogDog,

    The code I copied was incomplete. I have since reviewed message encoding to find that 7bit does not need to be decoded and hence there is no "decode" method for this encoding.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles