phpemailimapmbox

Open local mbox mail archive with imap_open() in PHP


I'm attempting to read an mbox email archive exported from another server locally, via file access, but for whatever reason everything I've tried fails. Is there some magical trick to parse a local file and access it with PHP's built-in IMAP functionality?


Solution

  • You should be able to use PHP's built-in IMAP functionality. Have you tried something like this:

    function openLocal($file_path) {     
        $mbox = imap_open("$file_path",'','');
       if (!mbox) {
          $errorMsg = imap_last_error(); // do something with the error...
         return false;
       } else {
          return true;
       }
    }
    

    And call this with the respective correct path:

    openLocal('/home/email/temp/mailbox')