FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Parsing mbox files with Windows Php
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Parsing mbox files with Windows Php [message #181666] Fri, 24 May 2013 21:57 Go to next message
Chuck Anderson is currently offline  Chuck Anderson
Messages: 63
Registered: September 2010
Karma: 0
Member
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.)

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).

--
*****************************
Chuck Anderson • Boulder, CO
http://cycletourist.com
Turn Off, Tune Out, Drop In
*****************************
Re: Parsing mbox files with Windows Php [message #181671 is a reply to message #181666] Fri, 24 May 2013 22:40 Go to previous messageGo to next message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma: 0
Member
Chuck Anderson wrote:
> 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 [...]

It may work under Cygwin[1]; probably that's worth a try.

[1] <http://www.cygwin.com/>

--
Christoph M. Becker
Re: Parsing mbox files with Windows Php [message #181678 is a reply to message #181666] Fri, 24 May 2013 23:16 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 5/24/2013 5:57 PM, 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.)
>
> 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).
>

Are you sure Thunderbird's files are in imap format? I didn't think
they were - I thought they were in some Thunderbird-specific format.

But also, if you're opening 'pathto/mboxfile', why is it complaining
about 'mboxfiles...'?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Parsing mbox files with Windows Php [message #181682 is a reply to message #181678] Fri, 24 May 2013 23:40 Go to previous messageGo to next message
Chuck Anderson is currently offline  Chuck Anderson
Messages: 63
Registered: September 2010
Karma: 0
Member
Jerry Stuckle wrote:
> On 5/24/2013 5:57 PM, 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.)
>>
>> 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).
>>
>
> Are you sure Thunderbird's files are in imap format?

I don't have the spec, but I have read as much. And the imap functions
do parse them nicely - on *nix.

> I didn't think they were - I thought they were in some
> Thunderbird-specific format.

Thunderbird (I am still in version 2) uses the mbox format. (I believe
that means that the beginning of a new email is denoted by a blank line
followed by "From - ...."). The rest is the usual email format, headers
until a double line feed denoting the beginning of the body. (Body
lines that happen to begin with "From" have to have "From" escaped in
those files.)

When saving a single email to a .eml file, before you can not parse it
with imap functions you must insert a dummy "From - " line (separate
from the usual From: header, this is "From - date") to the beginning of
the headers. Thunderbird places those into the mbox (multiple emails) file.

>
> But also, if you're opening 'pathto/mboxfile', why is it complaining
> about 'mboxfiles...'?

Sorry. I was using generic terms and switched terms (sloppy). The
error says it can not open the folder/file I specified. When I run the
exact same script on my shared Linux server (after uploading a sample
Thunderbird mail file), the imap functions produce output exactly like
they would if reading from a stream on the imap server.

--
*****************************
Chuck Anderson • Boulder, CO
http://cycletourist.com
Turn Off, Tune Out, Drop In
*****************************
Re: Parsing mbox files with Windows Php [message #181687 is a reply to message #181671] Sat, 25 May 2013 03:17 Go to previous messageGo to next message
Chuck Anderson is currently offline  Chuck Anderson
Messages: 63
Registered: September 2010
Karma: 0
Member
Christoph Becker wrote:
> Chuck Anderson wrote:
>
>> 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 [...]
>>
>
> It may work under Cygwin[1]; probably that's worth a try.
>
> [1] <http://www.cygwin.com/>
>

I guess there's more to Cygwin than I ever knew. I've only used
specific cygwin tools that I wanted - that required cygwin1.dll. I
never took a closer look at it. I don't (as yet) know how I would run
Php under Cygwin1. I believe I need to install a special Cygwin version
of Php. I'll have to learn how to run it under Cygwin1.

--
*****************************
Chuck Anderson • Boulder, CO
http://cycletourist.com
Turn Off, Tune Out, Drop In
*****************************
Re: Parsing mbox files with Windows Php [message #181690 is a reply to message #181671] Sat, 25 May 2013 07:30 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Christoph Becker wrote:

> Chuck Anderson wrote:
>> 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 [...]
>
> It may work under Cygwin[1]; probably that's worth a try.
>
> [1] <http://www.cygwin.com/>

<http://cygwin.com/packages/> does not contain “php”.


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
Re: Parsing mbox files with Windows Php [message #181699 is a reply to message #181690] Sat, 25 May 2013 14:19 Go to previous messageGo to next message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma: 0
Member
Thomas 'PointedEars' Lahn wrote:
> Christoph Becker wrote:
>
>> Chuck Anderson wrote:
>>> 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 [...]
>>
>> It may work under Cygwin[1]; probably that's worth a try.
>>
>> [1] <http://www.cygwin.com/>
>
> <http://cygwin.com/packages/> does not contain “php”.

Unfortunately not. One has to build PHP from the sources. I have done
so lately with the default configuration (so I have no experience
regarding the IMAP extension), to use it from the command line. I have
not yet tried to use it from a web server.

--
Christoph M. Becker
Re: Parsing mbox files with Windows Php [message #181700 is a reply to message #181699] Sat, 25 May 2013 15:19 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Christoph Becker wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Christoph Becker wrote:
>>> Chuck Anderson wrote:
>>>> 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 [...]
>>>
>>> It may work under Cygwin[1]; probably that's worth a try.
>>>
>>> [1] <http://www.cygwin.com/>
>>
>> <http://cygwin.com/packages/> does not contain “php”.
>
> Unfortunately not. One has to build PHP from the sources. I have done
> so lately with the default configuration (so I have no experience
> regarding the IMAP extension), to use it from the command line. […]

Have you built PHP successfully *for Cygwin*?


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Re: Parsing mbox files with Windows Php [message #181702 is a reply to message #181700] Sat, 25 May 2013 15:48 Go to previous messageGo to next message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma: 0
Member
Thomas 'PointedEars' Lahn wrote:
> Christoph Becker wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> Christoph Becker wrote:
>>>> Chuck Anderson wrote:
>>>> > 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 [...]
>>>>
>>>> It may work under Cygwin[1]; probably that's worth a try.
>>>>
>>>> [1] <http://www.cygwin.com/>
>>>
>>> <http://cygwin.com/packages/> does not contain “php”.
>>
>> Unfortunately not. One has to build PHP from the sources. I have done
>> so lately with the default configuration (so I have no experience
>> regarding the IMAP extension), to use it from the command line. […]
>
> Have you built PHP successfully *for Cygwin*?

Yes. Besides the PHP sources, I have only used cygwin packages.

$ php -i
phpinfo()
PHP Version => 5.4.15

System => CYGWIN_NT-5.1 RELIANT 1.7.18(0.263/5/3) 2013-04-19 10:39 i686
Build Date => May 19 2013 23:20:19
Configure Command => './configure'
[...]

--
Christoph M. Becker
Re: Parsing mbox files with Windows Php [message #181703 is a reply to message #181678] Sat, 25 May 2013 15:50 Go to previous messageGo to next message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
On Fri, 24 May 2013 19:16:06 -0400, Jerry Stuckle wrote:
> Are you sure Thunderbird's files are in imap format? I didn't think
> they were - I thought they were in some Thunderbird-specific format.

Nah, it's essentially mbox, just like Eudora before it. Which is
convenient because mostly just remembering to use binary transfers is
enough to get from Thunderbird to shell mail tools, and back again.

--
50. My main computers will have their own special operating system that
will be completely incompatible with standard IBM and Macintosh
powerbooks.
--Peter Anspach's list of things to do as an Evil Overlord
Re: Parsing mbox files with Windows Php [message #181704 is a reply to message #181666] Sat, 25 May 2013 16:08 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 24-05-2013 23:57, 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,

There are also scripts/tools to convert mbox to maildir format....

Maybe that could bring another way to solve this 'problem' ?
Re: Parsing mbox files with Windows Php [message #181705 is a reply to message #181666] Sat, 25 May 2013 16:14 Go to previous messageGo to next message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
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
Re: Parsing mbox files with Windows Php [message #181706 is a reply to message #181702] Sat, 25 May 2013 18:09 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Christoph Becker wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Christoph Becker wrote:
>>> Thomas 'PointedEars' Lahn wrote:
>>>> Christoph Becker wrote:
>>>> > Chuck Anderson wrote:
>>>> >> 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 [...]
>>>> >
>>>> > It may work under Cygwin[1]; probably that's worth a try.
>>>> >
>>>> > [1] <http://www.cygwin.com/>
>>>>
>>>> <http://cygwin.com/packages/> does not contain “php”.
>>>
>>> Unfortunately not. One has to build PHP from the sources. I have done
>>> so lately with the default configuration (so I have no experience
>>> regarding the IMAP extension), to use it from the command line. […]
>>
>> Have you built PHP successfully *for Cygwin*?
>
> Yes. Besides the PHP sources, I have only used cygwin packages.
>
> $ php -i
> phpinfo()
> PHP Version => 5.4.15
>
> System => CYGWIN_NT-5.1 RELIANT 1.7.18(0.263/5/3) 2013-04-19 10:39 i686
> Build Date => May 19 2013 23:20:19
> Configure Command => './configure'
> [...]

Thank you, that is what I wanted to read :)


Regards,

PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7(at)news(dot)demon(dot)co(dot)uk> (2004)
Re: Parsing mbox files with Windows Php [message #181707 is a reply to message #181705] Sat, 25 May 2013 22:39 Go to previous messageGo to next message
Chuck Anderson is currently offline  Chuck Anderson
Messages: 63
Registered: September 2010
Karma: 0
Member
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 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.... (:
>

I know ô¿Ô¬ .... It is not the upload that concerns me. It is the
resource usage when testing it on the entire structure all at once
(certainly more than one time). Perhaps it is no big deal. I simply do
not know.

Also, if done on the server I will need to upload files, process them to
a database, download a database dump, and then load that to the local
database. For simplicity alone, I would rather to do it locally with one
step - process to database. .... It is always easier to test and debug
on a local development machine.

I hoped someone else had cracked this nut, but I'm beginning to believe
that it is not crackable, so .... I will probably upload the entire
Thunderbird Mail folder structure to the remote host and try running my
script during low traffic hours. Once I verify it has worked 100%
(archived everything and saved the folder structure properly), I will
not have a need to do it again.

--
*****************************
Chuck Anderson • Boulder, CO
http://cycletourist.com
Turn Off, Tune Out, Drop In
*****************************
Re: Parsing mbox files with Windows Php [message #181711 is a reply to message #181707] Mon, 27 May 2013 03:11 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
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.

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
==================
Re: Parsing mbox files with Windows Php [message #181712 is a reply to message #181711] Mon, 27 May 2013 12:13 Go to previous messageGo to next message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma: 0
Member
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.

> 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!

--
Christoph M. Becker
Re: Parsing mbox files with Windows Php [message #181713 is a reply to message #181712] Mon, 27 May 2013 12:49 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
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.

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.

>> 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
==================
Re: Parsing mbox files with Windows Php [message #181714 is a reply to message #181713] Mon, 27 May 2013 13:25 Go to previous messageGo to next message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma: 0
Member
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.

> 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*.

However, the issue does still exist, even with the latest c-client
library, which is from 2007.

>>> 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!

--
Christoph M. Becker
Re: Parsing mbox files with Windows Php [message #181715 is a reply to message #181714] Mon, 27 May 2013 14:01 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
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
==================
Re: Parsing mbox files with Windows Php [message #181717 is a reply to message #181707] Mon, 27 May 2013 15:22 Go to previous messageGo to next message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
On Sat, 25 May 2013 16:39:14 -0600, Chuck Anderson wrote:
> Peter H. Coffin wrote:
>> On Fri, 24 May 2013 15:57:14 -0600, Chuck Anderson wrote:
>>
>>> $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).

Since the error messages about whether the file can be found, maybe it's
time to investigate WHERE exactly cclient is thinking it's pointing.
Because DocumentRoot isn't necessarily the same as $HOME. And when
you're using an actual IMAP server, they're nowhere close to alike.
But %UserProfile% might be a lot closer. So where's the base of what
cclient, on Windows, on your configuration, actually pointing? You may
have to haul out a test script that does opendir()/readdir() on '/'
and see what turns up, then find what directory those things that read
out are in. Then put the mail files under there, and make sure they're
world-readable.

[...]
> I hoped someone else had cracked this nut, but I'm beginning to believe
> that it is not crackable, so .... I will probably upload the entire
> Thunderbird Mail folder structure to the remote host and try running my
> script during low traffic hours. Once I verify it has worked 100%
> (archived everything and saved the folder structure properly), I will
> not have a need to do it again.

It's crackable, but IMHO, the number of PHP instances that are running
on Windows hosts that are doing anything user-related locally pales in
comparison to the number that are using user-related stuff on unix
hosts, which pales in comparison to the number that are doing only
webby-webby stuff for non-local clients. So the number of people that
have more than an academic interest in cracking this (much less
documenting the result) is probably only a handful worldwide, and some
of those probably just said "Screw it. I'll upload the mailfiles."

--
80. If my weakest troops fail to eliminate a hero, I will send out my
best troops instead of wasting time with progressively stronger
ones as he gets closer and closer to my fortress.
--Peter Anspach's list of things to do as an Evil Overlord
Re: Parsing mbox files with Windows Php [message #181718 is a reply to message #181715] Mon, 27 May 2013 16:08 Go to previous messageGo to next message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma: 0
Member
Jerry Stuckle wrote:
On 5/27/2013 9:25 AM, Christoph Becker wrote:
> Jerry Stuckle wrote:
>>
>> 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.

In <news:knreb5$roc$1(at)dont-email(dot)me> Chuck Anderson wrote:

> 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

>>> 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.

As I said before, the reported bug[1] was set to "not a bug".

>> 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?

Actually I was wrong. I tested with some recent PHP version (5.4.7),
and there the problem occured; but now I have checked the IMAP version
in use, and it is 2007e, despite the latest version is 2007f, for
whatever reason.

However, I made the following test script:

| $mbox = imap_open($_SERVER['DOCUMENT_ROOT'] . '/imap/mbox', '', '');
| var_dump($mbox);

On my local Windows XP machine with PHP 5.4.7 this prints:

| Warning: imap_open(): Couldn't open stream C:/xampp/htdocs
| /exp/imap/mbox in C:\xampp\htdocs\exp\imap\index.php on line 5
| boolean false
| Notice: Unknown: Can't open mailbox C:/xampp/htdocs/exp/imap/mbox:
| no such mailbox (errflg=2) in Unknown on line 0

On a Linux server with PHP 5.3.5 (IMAP version 2007e) it prints:

| resource(2) of type (imap)

Of course that is no proof, that imap_open() can't open an mbox file on
Windows, but it is some evidence at least.

> 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.

[1] <https://bugs.php.net/bug.php?id=39880>

--
Christoph M. Becker
Re: Parsing mbox files with Windows Php [message #181723 is a reply to message #181718] Mon, 27 May 2013 23:05 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 5/27/2013 12:08 PM, Christoph Becker wrote:
> Jerry Stuckle wrote:
> On 5/27/2013 9:25 AM, Christoph Becker wrote:
>> Jerry Stuckle wrote:
>>>
>>> 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.
>
> In <news:knreb5$roc$1(at)dont-email(dot)me> Chuck Anderson wrote:
>
>> 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
> '

And none of the purported statements he tried line up with the purported
results he posted. However, I guess that's a bit beyond your level of
comprehension.

>>>> 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.
>
> As I said before, the reported bug[1] was set to "not a bug".
>

Again, your comprehension is lacking. It was set as not a PHP bug.
However, once again, there is no indication this is the same problem as
a reported bug over six years old.

>>> 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?
>
> Actually I was wrong. I tested with some recent PHP version (5.4.7),
> and there the problem occured; but now I have checked the IMAP version
> in use, and it is 2007e, despite the latest version is 2007f, for
> whatever reason.
>

No! You, wrong? Can't be!

> However, I made the following test script:
>
> | $mbox = imap_open($_SERVER['DOCUMENT_ROOT'] . '/imap/mbox', '', '');
> | var_dump($mbox);
>
> On my local Windows XP machine with PHP 5.4.7 this prints:
>
> | Warning: imap_open(): Couldn't open stream C:/xampp/htdocs
> | /exp/imap/mbox in C:\xampp\htdocs\exp\imap\index.php on line 5
> | boolean false
> | Notice: Unknown: Can't open mailbox C:/xampp/htdocs/exp/imap/mbox:
> | no such mailbox (errflg=2) in Unknown on line 0
>

Not having any idea how your system is set up, I would say your test is
worthless.

> On a Linux server with PHP 5.3.5 (IMAP version 2007e) it prints:
>
> | resource(2) of type (imap)
>

See above.

> Of course that is no proof, that imap_open() can't open an mbox file on
> Windows, but it is some evidence at least.
>
>> 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.
>
> [1] <https://bugs.php.net/bug.php?id=39880>
>

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.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Parsing mbox files with Windows Php [message #181725 is a reply to message #181723] Mon, 27 May 2013 23:42 Go to previous messageGo to next message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma: 0
Member
Jerry Stuckle wrote:
> On 5/27/2013 12:08 PM, Christoph Becker wrote:
>> Jerry Stuckle wrote:
>> On 5/27/2013 9:25 AM, Christoph Becker wrote:
>>> Jerry Stuckle wrote:
>>>>
>>>> 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.
>>
>> In <news:knreb5$roc$1(at)dont-email(dot)me> Chuck Anderson wrote:
>>
>>> 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
>> '
>
> And none of the purported statements he tried line up with the purported
> results he posted. However, I guess that's a bit beyond your level of
> comprehension.

Indeed, the paths don't line up--thank you for making me aware of it, as
I have not checked that in the first place. However, let's concentrate
on my own test below.

>>>> > 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.
>>
>> As I said before, the reported bug[1] was set to "not a bug".
>>
>
> Again, your comprehension is lacking. It was set as not a PHP bug.
> However, once again, there is no indication this is the same problem as
> a reported bug over six years old.
>
>>>> 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?
>>
>> Actually I was wrong. I tested with some recent PHP version (5.4.7),
>> and there the problem occured; but now I have checked the IMAP version
>> in use, and it is 2007e, despite the latest version is 2007f, for
>> whatever reason.
>>
>
> No! You, wrong? Can't be!

Of course that can be. I am human, and humans make mistakes sometimes.
And of course, I'm able to admit, when I have done so.

>> However, I made the following test script:
>>
>> | $mbox = imap_open($_SERVER['DOCUMENT_ROOT'] . '/imap/mbox', '', '');
>> | var_dump($mbox);
>>
>> On my local Windows XP machine with PHP 5.4.7 this prints:
>>
>> | Warning: imap_open(): Couldn't open stream C:/xampp/htdocs
>> | /exp/imap/mbox in C:\xampp\htdocs\exp\imap\index.php on line 5
>> | boolean false
>> | Notice: Unknown: Can't open mailbox C:/xampp/htdocs/exp/imap/mbox:
>> | no such mailbox (errflg=2) in Unknown on line 0
>>
>
> Not having any idea how your system is set up, I would say your test is
> worthless.

Which information do you require? It's hard for me to recognize all
*necessary* information.

However, you might consider to run the test yourself on a system of your
choice.

>> On a Linux server with PHP 5.3.5 (IMAP version 2007e) it prints:
>>
>> | resource(2) of type (imap)
>>
>
> See above.
>
>> Of course that is no proof, that imap_open() can't open an mbox file on
>> Windows, but it is some evidence at least.
>>
>>> 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.
>>
>> [1] <https://bugs.php.net/bug.php?id=39880>
>>
>
> 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.

I also prefer to identify the problem; unfortunately my limited
knowledge and time make that hard to accomplish. If you like, you may
help out.

--
Christoph M. Becker
Re: Parsing mbox files with Windows Php [message #181726 is a reply to message #181725] Mon, 27 May 2013 23:50 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 5/27/2013 7:42 PM, Christoph Becker wrote:
> Jerry Stuckle wrote:
>> On 5/27/2013 12:08 PM, Christoph Becker wrote:
>>> Jerry Stuckle wrote:
>>> On 5/27/2013 9:25 AM, Christoph Becker wrote:
>>>> Jerry Stuckle wrote:
>>>> >
>>>> > 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.
>>>
>>> In <news:knreb5$roc$1(at)dont-email(dot)me> Chuck Anderson wrote:
>>>
>>>> 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
>>> '
>>
>> And none of the purported statements he tried line up with the purported
>> results he posted. However, I guess that's a bit beyond your level of
>> comprehension.
>
> Indeed, the paths don't line up--thank you for making me aware of it, as
> I have not checked that in the first place. However, let's concentrate
> on my own test below.
>

You are not the OP. I really don't care about your tests. They may or
may not apply to the OP's problem.

>>>> >> 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.
>>>
>>> As I said before, the reported bug[1] was set to "not a bug".
>>>
>>
>> Again, your comprehension is lacking. It was set as not a PHP bug.
>> However, once again, there is no indication this is the same problem as
>> a reported bug over six years old.
>>
>>>> > 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?
>>>
>>> Actually I was wrong. I tested with some recent PHP version (5.4.7),
>>> and there the problem occured; but now I have checked the IMAP version
>>> in use, and it is 2007e, despite the latest version is 2007f, for
>>> whatever reason.
>>>
>>
>> No! You, wrong? Can't be!
>
> Of course that can be. I am human, and humans make mistakes sometimes.
> And of course, I'm able to admit, when I have done so.
>
>>> However, I made the following test script:
>>>
>>> | $mbox = imap_open($_SERVER['DOCUMENT_ROOT'] . '/imap/mbox', '', '');
>>> | var_dump($mbox);
>>>
>>> On my local Windows XP machine with PHP 5.4.7 this prints:
>>>
>>> | Warning: imap_open(): Couldn't open stream C:/xampp/htdocs
>>> | /exp/imap/mbox in C:\xampp\htdocs\exp\imap\index.php on line 5
>>> | boolean false
>>> | Notice: Unknown: Can't open mailbox C:/xampp/htdocs/exp/imap/mbox:
>>> | no such mailbox (errflg=2) in Unknown on line 0
>>>
>>
>> Not having any idea how your system is set up, I would say your test is
>> worthless.
>
> Which information do you require? It's hard for me to recognize all
> *necessary* information.
>

The only worthwhile test is the one that duplicates the OP's problem.
So far I haven't seen enough information to do that.

> However, you might consider to run the test yourself on a system of your
> choice.
>

I will - WHEN I have sufficient information.

>>> On a Linux server with PHP 5.3.5 (IMAP version 2007e) it prints:
>>>
>>> | resource(2) of type (imap)
>>>
>>
>> See above.
>>
>>> Of course that is no proof, that imap_open() can't open an mbox file on
>>> Windows, but it is some evidence at least.
>>>
>>>> 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.
>>>
>>> [1] <https://bugs.php.net/bug.php?id=39880>
>>>
>>
>> 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.
>
> I also prefer to identify the problem; unfortunately my limited
> knowledge and time make that hard to accomplish. If you like, you may
> help out.
>

Then I suggest you increase both your knowledge and your time. That's
what you need to do to help others (I've been doing it for over 25 years).

I will help the OP identify his problem. I will NOT jump to the
conclusion that a six-year-old bug report is his trouble.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Parsing mbox files with Windows Php [message #181727 is a reply to message #181711] Mon, 27 May 2013 23:51 Go to previous messageGo to next message
Chuck Anderson is currently offline  Chuck Anderson
Messages: 63
Registered: September 2010
Karma: 0
Member
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.
>
> 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!
>
>

The above really is all there is to it.

Note:
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

Here is a cut and paste of the script imap_open_eml.php:

<?php

echo '<pre style="text-align: left;">'; // for more readable output

imap_open('localhost/imap/mboxfiles/Trash', '', ''); // same as 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

echo '</pre>';

?>

Here is the resultant output:
----------------------------

Warning: imap_open(): Couldn't open stream localhost/imap/mboxfiles/Trash in C:\localhost\utilities\imap\imap_open_eml.php on line 4

Warning: imap_open(): Couldn't open stream /imap/mboxfiles/Trash in C:\localhost\utilities\imap\imap_open_eml.php on line 5

Warning: imap_open(): Couldn't open stream mboxfiles/Trash in C:\localhost\utilities\imap\imap_open_eml.php on line 6

Warning: imap_open(): Couldn't open stream c:/localhost/imap/mboxfiles/Trash in C:\localhost\utilities\imap\imap_open_eml.php on line 7

Notice: Unknown: Can't open mailbox localhost/imap/mboxfiles/Trash: no
such mailbox (errflg=2) in Unknown on line 0
Notice: Unknown: Can't open mailbox /imap/mboxfiles/Trash: no such
mailbox (errflg=2) in Unknown on line 0
Notice: Unknown: Can't open mailbox mboxfiles/Trash: no such mailbox
(errflg=2) in Unknown on line 0
Notice: Unknown: Can't open mailbox c:/localhost/imap/mboxfiles/Trash:
no such mailbox (errflg=2) in Unknown on line 0

--
*****************************
Chuck Anderson • Boulder, CO
http://cycletourist.com
Turn Off, Tune Out, Drop In
*****************************
Re: Parsing mbox files with Windows Php (correction - ignore previous) [message #181729 is a reply to message #181727] Tue, 28 May 2013 00:20 Go to previous messageGo to next message
Chuck Anderson is currently offline  Chuck Anderson
Messages: 63
Registered: September 2010
Karma: 0
Member
Chuck Anderson wrote:

Been studying storing/retrieving tree structures in MySQL all day and
brain fried. I had the wrong folder names in my script in the previous
post. The corrected script and it's output is below (same result).

> 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:
>>>> > 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.
>>>

On Windows
c:/localhost is the document root
c:/localhost/imap is where the Php scripts are located.
c:/localhost/imap/eml is where the mbox file "Trash" is located (a
Thunderbird mbox file)

Entire Contents of imap_open_eml.php
<?php

echo '<pre style="text-align: left;">';

imap_open('localhost/imap/eml/Trash', '', ''); // same as relative to
$HOME on *nix
imap_open('/imap/eml/Trash', '', ''); // absolute path from DOCUMENT_ROOT
imap_open('eml/Trash', '', ''); // relative path
imap_open('c:/localhost/imap/eml/Trash', '', ''); // real path on disk

echo '</pre>';

?>
---------- end imap_open_eml.php ------------

Resultant output:

Warning: imap_open(): Couldn't open stream localhost/imap/eml/Trash in C:\localhost\utilities\imap\imap_open_eml.php on line 5

Warning: imap_open(): Couldn't open stream /imap/eml/Trash in C:\localhost\utilities\imap\imap_open_eml.php on line 6

Warning: imap_open(): Couldn't open stream eml/Trash in C:\localhost\utilities\imap\imap_open_eml.php on line 7

Warning: imap_open(): Couldn't open stream c:/localhost/imap/eml/Trash in C:\localhost\utilities\imap\imap_open_eml.php on line 8

Notice: Unknown: Can't open mailbox localhost/imap/eml/Trash: no such
mailbox (errflg=2) in Unknown on line 0 Notice: Unknown: Can't open
mailbox /imap/eml/Trash: no such mailbox (errflg=2) in Unknown on line 0
Notice: Unknown: Can't open mailbox eml/Trash: no such mailbox
(errflg=2) in Unknown on line 0 Notice: Unknown: Can't open mailbox
c:/localhost/imap/eml/Trash: no such mailbox (errflg=2) in Unknown on
line 0

--
*****************************
Chuck Anderson • Boulder, CO
http://cycletourist.com
Turn Off, Tune Out, Drop In
*****************************
Re: Parsing mbox files with Windows Php [message #181731 is a reply to message #181717] Tue, 28 May 2013 03:15 Go to previous messageGo to next message
Chuck Anderson is currently offline  Chuck Anderson
Messages: 63
Registered: September 2010
Karma: 0
Member
Peter H. Coffin wrote:
> On Sat, 25 May 2013 16:39:14 -0600, Chuck Anderson wrote:
>
>> Peter H. Coffin wrote:
>>
>>> On Fri, 24 May 2013 15:57:14 -0600, Chuck Anderson wrote:
>>>
>>>
>>>> $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).
>>
>
> Since the error messages about whether the file can be found, maybe it's
> time to investigate WHERE exactly cclient is thinking it's pointing.
> Because DocumentRoot isn't necessarily the same as $HOME.

I was thinking it "could" be c:/ (the root of the drive that localhost
is on), but I also don't see a real equivalence.

> And when you're using an actual IMAP server, they're nowhere close to alike.
> But %UserProfile% might be a lot closer.

That would be C:/Users/Username

Hey! It found it there:

When I moved the mbox file 'Trash' to 'C:/Users/Username' and used:
imap_open('Trash', '', ''); // Trash is in %UserProfile%

The low level error changed to:

Notice: Unknown: Trash (file C:\Users\Owner\Trash) is not in valid
mailbox format (errflg=2) in Unknown on line 0

If I upload that very file to my linux host, imap_open works.

I'll try tinkering with line endings .... and whatever else I can think
of ..... later.

BTW, I tried opendir('/localhost/utilities/imap/eml/Trash') and it was
able to read from there just fine, but perhaps that's moot now.

> So where's the base of what cclient, on Windows, on your configuration, actually pointing?

Apparently that c-client is basing all folder references to %UserProfile%.

>> I hoped someone else had cracked this nut, but I'm beginning to believe
>> that it is not crackable, so ....
> It's crackable, but IMHO, the number of PHP instances that are running
> on Windows hosts that are doing anything user-related locally pales in
> comparison to the number that are using user-related stuff on unix
> hosts, which pales in comparison to the number that are doing only
> webby-webby stuff for non-local clients. So the number of people that
> have more than an academic interest in cracking this (much less
> documenting the result) is probably only a handful worldwide, and some
> of those probably just said "Screw it. I'll upload the mailfiles."
>

Not quite yet. I might get this.

[And ... yes, ... I use Php (WAMP) almost exclusively now for my own
browser based apps.]

--
*****************************
Chuck Anderson • Boulder, CO
http://cycletourist.com
Turn Off, Tune Out, Drop In
*****************************
Re: Parsing mbox files with Windows Php [message #181735 is a reply to message #181731] Tue, 28 May 2013 16:23 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 5/27/2013 11:15 PM, Chuck Anderson wrote:
> Peter H. Coffin wrote:
>> On Sat, 25 May 2013 16:39:14 -0600, Chuck Anderson wrote:
>>> Peter H. Coffin wrote:
>>>> On Fri, 24 May 2013 15:57:14 -0600, Chuck Anderson wrote:
>>>> > $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).
>>
>> Since the error messages about whether the file can be found, maybe it's
>> time to investigate WHERE exactly cclient is thinking it's pointing.
>> Because DocumentRoot isn't necessarily the same as $HOME.
>
> I was thinking it "could" be c:/ (the root of the drive that localhost
> is on), but I also don't see a real equivalence.
>
>> And when you're using an actual IMAP server, they're nowhere close to
>> alike.
>> But %UserProfile% might be a lot closer.
>
> That would be C:/Users/Username
>
> Hey! It found it there:
>
> When I moved the mbox file 'Trash' to 'C:/Users/Username' and used:
> imap_open('Trash', '', ''); // Trash is in %UserProfile%
>
> The low level error changed to:
>
> Notice: Unknown: Trash (file C:\Users\Owner\Trash) is not in valid
> mailbox format (errflg=2) in Unknown on line 0
>
> If I upload that very file to my linux host, imap_open works.
>
> I'll try tinkering with line endings .... and whatever else I can think
> of ..... later.
>
> BTW, I tried opendir('/localhost/utilities/imap/eml/Trash') and it was
> able to read from there just fine, but perhaps that's moot now.
>
>> So where's the base of what cclient, on Windows, on your
>> configuration, actually pointing?
>
> Apparently that c-client is basing all folder references to %UserProfile%.
>
>>> I hoped someone else had cracked this nut, but I'm beginning to
>>> believe that it is not crackable, so ....
>> It's crackable, but IMHO, the number of PHP instances that are running
>> on Windows hosts that are doing anything user-related locally pales in
>> comparison to the number that are using user-related stuff on unix
>> hosts, which pales in comparison to the number that are doing only
>> webby-webby stuff for non-local clients. So the number of people that
>> have more than an academic interest in cracking this (much less
>> documenting the result) is probably only a handful worldwide, and some
>> of those probably just said "Screw it. I'll upload the mailfiles."
>
> Not quite yet. I might get this.
>
> [And ... yes, ... I use Php (WAMP) almost exclusively now for my own
> browser based apps.]
>

Chuck,

I'm glad you found the problem.

I've been looking through the imap code most of the morning, but it
doesn't look like the same code that comes with Windows (this was from U
of Washington). There is some code in there for opening a file, but
nothing dealing with Windows paths. There is code to open a file, but
there doesn't seem to be a difference between Windows and Linux code in
that area (other than the differences between OS handling). But nothing
to do with "C:\Users\Username" at all.

I suspect you're right - line endings may be a problem.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Parsing mbox files with Windows Php [message #181738 is a reply to message #181731] Tue, 28 May 2013 22:08 Go to previous messageGo to next message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma: 0
Member
Chuck Anderson wrote:
> Not quite yet. I might get this.

I was able to build the IMAP extension under Cygwin. I exported some
news with the Thunderbird Add-On ImportExportTools to a file in mbox
format and copied that to my home directory.

$ php -r '$imap=imap_open("test.mbox", "",
"");var_dump(imap_check($imap));'
object(stdClass)#1 (5) {
["Date"]=>
string(31) "Tue, 28 May 2013 23:53:42 +0200"
["Driver"]=>
string(4) "unix"
["Mailbox"]=>
string(19) "/home/cmb/test.mbox"
["Nmsgs"]=>
int(11)
["Recent"]=>
int(0)
}

The driver is reported as "unix"! In PHP 5.4.15 in ext/imap/php_imap.c
line 839[1] this driver is linked in only, if the system is not Win32
(PHP_WIN32).

imap_open()ing an Inbox of Thunderbird directly reports the "dummy"
driver and 0 messages (same as for an empty file).

So the solution to be able to read Thunderbird mailboxes under Windows
might to be to export them to a format that is handled by the "mbx"
driver. I do not know, how this can be accomplished.

[1] <http://lxr.php.net/xref/PHP_5_4/ext/imap/php_imap.c#839>

--
Christoph M. Becker
Re: Parsing mbox files with Windows Php [message #181739 is a reply to message #181726] Tue, 28 May 2013 22:17 Go to previous messageGo to next message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma: 0
Member
Jerry Stuckle wrote:
> On 5/27/2013 7:42 PM, Christoph Becker wrote:
>> Jerry Stuckle wrote:
>>> 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.
>>
>> I also prefer to identify the problem; unfortunately my limited
>> knowledge and time make that hard to accomplish. If you like, you may
>> help out.
>>
>
> Then I suggest you increase both your knowledge and your time. That's
> what you need to do to help others (I've been doing it for over 25 years).

Thanks for the hint. I'll do my best.

> I will help the OP identify his problem.

Good luck.

> I will NOT jump to the
> conclusion that a six-year-old bug report is his trouble.

Indeed, relying on the comments on the bug report was not the best idea.

--
Christoph M. Becker
Re: Parsing mbox files with Windows Php [message #181741 is a reply to message #181735] Tue, 28 May 2013 23:56 Go to previous messageGo to next message
Chuck Anderson is currently offline  Chuck Anderson
Messages: 63
Registered: September 2010
Karma: 0
Member
Jerry Stuckle wrote:
> On 5/27/2013 11:15 PM, Chuck Anderson wrote:
>> Peter H. Coffin wrote:
>>> On Sat, 25 May 2013 16:39:14 -0600, Chuck Anderson wrote:
>>>> Peter H. Coffin wrote:
>>>> > On Fri, 24 May 2013 15:57:14 -0600, Chuck Anderson wrote:
>>>> >> $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).
>>>
>>> Since the error messages about whether the file can be found, maybe
>>> it's
>>> time to investigate WHERE exactly cclient is thinking it's pointing.
>>> Because DocumentRoot isn't necessarily the same as $HOME.
>>
>> I was thinking it "could" be c:/ (the root of the drive that localhost
>> is on), but I also don't see a real equivalence.
>>
>>> And when you're using an actual IMAP server, they're nowhere close to
>>> alike.
>>> But %UserProfile% might be a lot closer.
>>
>> That would be C:/Users/Username
>>
>> Hey! It found it there:
>>
>> When I moved the mbox file 'Trash' to 'C:/Users/Username' and used:
>> imap_open('Trash', '', ''); // Trash is in %UserProfile%
>>
>> The low level error changed to:
>>
>> Notice: Unknown: Trash (file C:\Users\Owner\Trash) is not in valid
>> mailbox format (errflg=2) in Unknown on line 0
>>
>> If I upload that very file to my linux host, imap_open works.
>>
>> I'll try tinkering with line endings .... and whatever else I can think
>> of ..... later.
>>
>> BTW, I tried opendir('/localhost/utilities/imap/eml/Trash') and it was
>> able to read from there just fine, but perhaps that's moot now.
>>
>>> So where's the base of what cclient, on Windows, on your
>>> configuration, actually pointing?
>>
>> Apparently that c-client is basing all folder references to
>> %UserProfile%.
>>
>>>> I hoped someone else had cracked this nut, but I'm beginning to
>>>> believe that it is not crackable, so ....
>>> It's crackable, but IMHO, the number of PHP instances that are running
>>> on Windows hosts that are doing anything user-related locally pales in
>>> comparison to the number that are using user-related stuff on unix
>>> hosts, which pales in comparison to the number that are doing only
>>> webby-webby stuff for non-local clients. So the number of people that
>>> have more than an academic interest in cracking this (much less
>>> documenting the result) is probably only a handful worldwide, and some
>>> of those probably just said "Screw it. I'll upload the mailfiles."
>>
>> Not quite yet. I might get this.
>>
>> [And ... yes, ... I use Php (WAMP) almost exclusively now for my own
>> browser based apps.]
>>
>
> Chuck,
>
> I'm glad you found the problem.
>
> I've been looking through the imap code most of the morning, but it
> doesn't look like the same code that comes with Windows (this was from
> U of Washington). There is some code in there for opening a file, but
> nothing dealing with Windows paths. There is code to open a file, but
> there doesn't seem to be a difference between Windows and Linux code
> in that area (other than the differences between OS handling). But
> nothing to do with "C:\Users\Username" at all.
>
> I suspect you're right - line endings may be a problem.

I have tried every variation of line endings in the mbox file with no
luck. I also tried adding an extra line feed to the beginning - tried
variations of the first line ("From ....") - no luck - same error
(mailbox format is not valid).

And now Christopher Becker seems to have found the problem in his latest
post.

--
*****************************
Chuck Anderson • Boulder, CO
http://cycletourist.com
Turn Off, Tune Out, Drop In
*****************************
Re: Parsing mbox files with Windows Php [message #181742 is a reply to message #181741] Wed, 29 May 2013 02:27 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 5/28/2013 7:56 PM, Chuck Anderson wrote:
> Jerry Stuckle wrote:
>> On 5/27/2013 11:15 PM, Chuck Anderson wrote:
>>> Peter H. Coffin wrote:
>>>> On Sat, 25 May 2013 16:39:14 -0600, Chuck Anderson wrote:
>>>> > Peter H. Coffin wrote:
>>>> >> On Fri, 24 May 2013 15:57:14 -0600, Chuck Anderson wrote:
>>>> >>> $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).
>>>>
>>>> Since the error messages about whether the file can be found, maybe
>>>> it's
>>>> time to investigate WHERE exactly cclient is thinking it's pointing.
>>>> Because DocumentRoot isn't necessarily the same as $HOME.
>>>
>>> I was thinking it "could" be c:/ (the root of the drive that localhost
>>> is on), but I also don't see a real equivalence.
>>>
>>>> And when you're using an actual IMAP server, they're nowhere close to
>>>> alike.
>>>> But %UserProfile% might be a lot closer.
>>>
>>> That would be C:/Users/Username
>>>
>>> Hey! It found it there:
>>>
>>> When I moved the mbox file 'Trash' to 'C:/Users/Username' and used:
>>> imap_open('Trash', '', ''); // Trash is in %UserProfile%
>>>
>>> The low level error changed to:
>>>
>>> Notice: Unknown: Trash (file C:\Users\Owner\Trash) is not in valid
>>> mailbox format (errflg=2) in Unknown on line 0
>>>
>>> If I upload that very file to my linux host, imap_open works.
>>>
>>> I'll try tinkering with line endings .... and whatever else I can think
>>> of ..... later.
>>>
>>> BTW, I tried opendir('/localhost/utilities/imap/eml/Trash') and it was
>>> able to read from there just fine, but perhaps that's moot now.
>>>
>>>> So where's the base of what cclient, on Windows, on your
>>>> configuration, actually pointing?
>>>
>>> Apparently that c-client is basing all folder references to
>>> %UserProfile%.
>>>
>>>> > I hoped someone else had cracked this nut, but I'm beginning to
>>>> > believe that it is not crackable, so ....
>>>> It's crackable, but IMHO, the number of PHP instances that are running
>>>> on Windows hosts that are doing anything user-related locally pales in
>>>> comparison to the number that are using user-related stuff on unix
>>>> hosts, which pales in comparison to the number that are doing only
>>>> webby-webby stuff for non-local clients. So the number of people that
>>>> have more than an academic interest in cracking this (much less
>>>> documenting the result) is probably only a handful worldwide, and some
>>>> of those probably just said "Screw it. I'll upload the mailfiles."
>>>
>>> Not quite yet. I might get this.
>>>
>>> [And ... yes, ... I use Php (WAMP) almost exclusively now for my own
>>> browser based apps.]
>>>
>>
>> Chuck,
>>
>> I'm glad you found the problem.
>>
>> I've been looking through the imap code most of the morning, but it
>> doesn't look like the same code that comes with Windows (this was from
>> U of Washington). There is some code in there for opening a file, but
>> nothing dealing with Windows paths. There is code to open a file, but
>> there doesn't seem to be a difference between Windows and Linux code
>> in that area (other than the differences between OS handling). But
>> nothing to do with "C:\Users\Username" at all.
>>
>> I suspect you're right - line endings may be a problem.
>
> I have tried every variation of line endings in the mbox file with no
> luck. I also tried adding an extra line feed to the beginning - tried
> variations of the first line ("From ....") - no luck - same error
> (mailbox format is not valid).
>
> And now Christopher Becker seems to have found the problem in his latest
> post.
>

Yes, if you want to use cygwin, that will work fine.

Looking more at the php imap module, it looks like it links to Windows
libraries, so no source code is available (and what it's doing in the
code is anyone's guess). You might be able to compile the imap source
from U of Washington and link that into the php module. Of course, this
would be non-standard and you'd have to redo it with every release. But
it's another option if you don't want to use cygwin.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Parsing mbox files with Windows Php [message #181753 is a reply to message #181741] Wed, 29 May 2013 13:23 Go to previous message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma: 0
Member
Chuck Anderson wrote:
> And now Christopher Becker seems to have found the problem in his latest
> post.

And it seems I have found a viable solution now. In the UW IMAP FAQs[1]
I found the missing information on how to convert an arbitrary mailbox
to an mbxdriver compatible format (which is actually a binary format).
Creating a new mailbox with

mailutils create #driver.mbx/mailbox

was not possible, so I rebuilt the IMAP tools with CREATEPROTO=mbxproto
as described in the FAQ article. After that I was able to do

mailutils copy old-mailbox new-mailbox

The resulting file new-mailbox could be opened and processed under
Windows (binary distribution of PHP 5.4.7).

[1] <http://www.washington.edu/imap/IMAP-FAQs/#4.5>

--
Christoph M. Becker
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: why php echo does not show up in HTML?
Next Topic: Exhaustive memory allocation using arrays
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Dec 22 10:39:31 GMT 2024

Total time taken to generate the page: 0.02761 seconds