Re: Parsing mbox files with Windows Php [message #181715 is a reply to message #181714] |
Mon, 27 May 2013 14:01 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 5/27/2013 9:25 AM, Christoph Becker wrote:
> Jerry Stuckle wrote:
>> On 5/27/2013 8:13 AM, Christoph Becker wrote:
>>> Jerry Stuckle wrote:
>>>> On 5/25/2013 6:39 PM, Chuck Anderson wrote:
>>>> > Peter H. Coffin wrote:
>>>> >> 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.
>>>> >>> - 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 used generic paths and filenames because I had tried several
>>>> > variations.
>>>> >
>>>> > I have learned that imap_open only works on a file - on a *nix web
>>>> > server - if the path to the mbox file is relative to $HOME. I have not
>>>> > found any official documentation, just forum posts saying so, and
>>>> > ... it
>>>> > is the only way I have been able to make it work.
>>>> >
>>>> > So, imap_open works for me (on the remote Linux host) if, and only
>>>> > if, I
>>>> > use:
>>>> > imap_open ('public_html/mboxfiles/Trash', '', '')
>>>> > // Trash is an mbox file I uploaded directly from my Thunderbird
>>>> > Profile
>>>> >
>>>> > On Windows
>>>> > c:/localhost is the document root
>>>> > c:/localhost/imap is where the Php scripts are located.
>>>> > c:/localhost/imap/mboxfiles is where the mbox file "Trash" is located
>>>> >
>>>> > I have tried:
>>>> > imap_open('localhost/imap/mboxfiles/Trash', '', ''); // equivalent of
>>>> > being relative to $HOME on *nix
>>>> > imap_open('/imap/mboxfiles/Trash', '', ''); // absolute path from
>>>> > document root
>>>> > imap_open('mboxfiles/Trash', '', ''); // relative path
>>>> > imap_open('c:/localhost/imap/mboxfiles/Trash', '', ''); // real path on
>>>> > disk
>>>> >
>>>> > On Windows I always get these two errors (the file path changes
>>>> > accordingly):
>>>> >
>>>> > - Warning: imap_open(): Couldn't open stream
>>>> > localhost/utilities/imap/eml/Trash in
>>>> > localhost\utilities\imap\imap_save_mbox_file.php on line 127
>>>> >
>>>> > - Notice: Unknown: Can't open mailbox
>>>> > localhost/utilities/imap/eml/Trash: no such mailbox (errflg=2) in
>>>> > Unknown on line 0
>>>> >
>>>> > I have read that the second error is coming from the c-client (errflg=2
>>>> > comes from there).
>>>> >
>>>>
>>>> I don't see any of the code you listed listing the directories
>>>> imap_open() is looking in.
>>>
>>> There seems to be a misunderstanding. Chuck is not trying to open an
>>> IMAP stream to a mail *server*, but instead to an mbox *file*.
>>> Apparently this works on Linux, but not on Windows. According to
>>> <https://bugs.php.net/bug.php?id=39880> this seems to be a problem of
>>> the c-client library on Windows.
>>>
>>
>> No, there is no misunderstanding. But he has NOT been clear on his code
>> and resulting messages.
>
> Chuck has posted the code that fails on Windows, but works on Linux, and
> posted the according error messages.
>
He has not posted matching code and error messages.
>> Also, that bug is over six years old. I have no idea if the bug still
>> exists or not. However, I do not consider a bug that old to still be
>> valid until proven so.
>
> The issue's state was changed to "not a bug" in 2006 already. I
> consider this to be correct, but not for the reason given in the
> comments. IMO the valid reason to see it as "not a bug" is, that it's
> not documented that imap_open() can be used for mbox *files*.
>
Correction - not a PHP bug. I have seen no reference to any bug being
pursued in IMAP code.
> However, the issue does still exist, even with the latest c-client
> library, which is from 2007.
>
And your proof that it exists in his copy of the code is?
Unlike you, I'm not willing to jump to conclusions based on over six
year old bug reports. I prefer to identify the problem. It may or may
not be as you claim.
>>>> Once again (and for the LAST TIME):
>>>>
>>>> What is the *EXACT CODE* you are using. And what is the *EXACT MESSAGE*
>>>> you get in response?
>>>>
>>>> We can't help you if you give incomplete/confusing/incorrect
>>>> information!
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|