Re: Parsing mbox files with Windows Php [message #181705 is a reply to message #181666] |
Sat, 25 May 2013 16:14 |
Peter H. Coffin
Messages: 245 Registered: September 2010
Karma:
|
Senior Member |
|
|
On Fri, 24 May 2013 15:57:14 -0600, Chuck Anderson wrote:
>
> I have been slowly building a Php/MySQL based IMAP email client. The
> Php IMAP functions are well documented and easy to use. I store
> messages in a MySQL database (attachments in the file system) for ease
> of organization, maintenance, backup and searching. I like it enough
> that I want to add my existing archive of email in Thunderbird. To do
> so, I need to parse mbox files and extract message headers, parts, and
> attachments. Thankfully, the Php IMAP functions can be used to open and
> parse an mbox file (or even a single .eml file) as well as opening a
> stream to the server.
>
> Using this functionality I can write a script to run on my WAMP
> development machine that reads the Thunderbird folder structure, parses
> the mbox files and saves individual messages along with their
> folder/subfolder path in the Thunderbird folder hierarchy. It should be
> as easy as pointing it to the top of the folder structure and letting it
> do all the work from there.
>
> Unfortunately, it appears that the Windows Php binary is unable to
> connect to an mbox file, so to make my job easy, I would have to upload
> the entire folder structure (it is about 200MBs) to my shared host and
> process it there. I would much rather "toy around" with this process on
> my Windows development machine and not on the shared host.
>
> There is a Php bug filed for this, but it was determined that the
> "underlying c-client function is unable to open a file."
> https://bugs.php.net/bug.php?id=39880 - closed as "not a bug."
>
> $mbox = imap_open('pathto/mboxfile', '', '') // works on *nix, but not
> on Windows.
> - Warning: imap_open(): Couldn't open stream mboxfiles/Inbox ....
> - Notice: Unknown: Can't open mailbox mboxfiles/Inbox: no such mailbox
> (errflg=2) in Unknown on line 0.
> (This second error is the one coming from the underlying c-client
> function.)
Okay, step one: quit munging stuff around and give us the EXACT code,
the EXACT contents of variables involved, and the EXACT error messages.
You're not revealing national secrets by posting paths to filenames, and
what the problem is may be in what you're changing to be more general.
> I believe this is a dead end but want to check if anyone has happened to
> figure out a way to make this work in Windows - or if you know of a
> separate mbox file parser that would be fairly simple to integrate with
> my current Php IMAP based scripts - dependent on the output of
> imap_fetchstructure, imap_headerinfo, imap_fetchbody(parts).
>
> If not, I will probably build a form that lets me select individual
> (smaller) sections of the folder hierarchy to process individually
> (tedious and prone to error).
Of course, by the time you're done with that, the 200MB transfer would
have been LONG finished and you'd have your goal accomplished on the
hosted server.... (:
--
19. I will not have a daughter. She would be as beautiful as she was
evil, but one look at the hero's rugged countenance and she'd betray
her own father.
--Peter Anspach's list of things to do as an Evil Overlord
|
|
|