Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #9683

Re: Parsing mbox files with Windows Php

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: Parsing mbox files with Windows Php
Date 2013-05-28 12:23 -0400
Organization A noiseless patient Spider
Message-ID <ko2let$ftn$1@dont-email.me> (permalink)
References <knongf$e81$1@dont-email.me> <slrnkq1orr.msg.hellsop@nibelheim.ninehells.com> <knreb5$roc$1@dont-email.me> <slrnkq6ui2.msg.hellsop@nibelheim.ninehells.com> <ko178g$dou$1@dont-email.me>

Show all headers | View raw


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@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Parsing mbox files with Windows Php Chuck Anderson <cycletourist@invalid.invalid> - 2013-05-24 15:57 -0600
  Re: Parsing mbox files with Windows Php Christoph Becker <cmbecker69@gmx.de> - 2013-05-25 00:40 +0200
    Re: Parsing mbox files with Windows Php Chuck Anderson <cycletourist@invalid.invalid> - 2013-05-24 21:17 -0600
    Re: Parsing mbox files with Windows Php Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-25 09:30 +0200
      Re: Parsing mbox files with Windows Php Christoph Becker <cmbecker69@gmx.de> - 2013-05-25 16:19 +0200
        Re: Parsing mbox files with Windows Php Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-25 17:19 +0200
          Re: Parsing mbox files with Windows Php Christoph Becker <cmbecker69@gmx.de> - 2013-05-25 17:48 +0200
            Re: Parsing mbox files with Windows Php Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-25 20:09 +0200
  Re: Parsing mbox files with Windows Php Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-24 19:16 -0400
    Re: Parsing mbox files with Windows Php Chuck Anderson <cycletourist@invalid.invalid> - 2013-05-24 17:40 -0600
    Re: Parsing mbox files with Windows Php "Peter H. Coffin" <hellsop@ninehells.com> - 2013-05-25 10:50 -0500
  Re: Parsing mbox files with Windows Php Luuk <luuk@invalid.lan> - 2013-05-25 18:08 +0200
  Re: Parsing mbox files with Windows Php "Peter H. Coffin" <hellsop@ninehells.com> - 2013-05-25 11:14 -0500
    Re: Parsing mbox files with Windows Php Chuck Anderson <cycletourist@invalid.invalid> - 2013-05-25 16:39 -0600
      Re: Parsing mbox files with Windows Php Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-26 23:11 -0400
        Re: Parsing mbox files with Windows Php Christoph Becker <cmbecker69@gmx.de> - 2013-05-27 14:13 +0200
          Re: Parsing mbox files with Windows Php Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-27 08:49 -0400
            Re: Parsing mbox files with Windows Php Christoph Becker <cmbecker69@gmx.de> - 2013-05-27 15:25 +0200
              Re: Parsing mbox files with Windows Php Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-27 10:01 -0400
                Re: Parsing mbox files with Windows Php Christoph Becker <cmbecker69@gmx.de> - 2013-05-27 18:08 +0200
                Re: Parsing mbox files with Windows Php Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-27 19:05 -0400
                Re: Parsing mbox files with Windows Php Christoph Becker <cmbecker69@gmx.de> - 2013-05-28 01:42 +0200
                Re: Parsing mbox files with Windows Php Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-27 19:50 -0400
                Re: Parsing mbox files with Windows Php Christoph Becker <cmbecker69@gmx.de> - 2013-05-29 00:17 +0200
        Re: Parsing mbox files with Windows Php Chuck Anderson <cycletourist@invalid.invalid> - 2013-05-27 17:51 -0600
          Re: Parsing mbox files with Windows Php (correction - ignore previous) Chuck Anderson <cycletourist@invalid.invalid> - 2013-05-27 18:20 -0600
      Re: Parsing mbox files with Windows Php "Peter H. Coffin" <hellsop@ninehells.com> - 2013-05-27 10:22 -0500
        Re: Parsing mbox files with Windows Php Chuck Anderson <cycletourist@invalid.invalid> - 2013-05-27 21:15 -0600
          Re: Parsing mbox files with Windows Php Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-28 12:23 -0400
            Re: Parsing mbox files with Windows Php Chuck Anderson <cycletourist@invalid.invalid> - 2013-05-28 17:56 -0600
              Re: Parsing mbox files with Windows Php Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-28 22:27 -0400
              Re: Parsing mbox files with Windows Php Christoph Becker <cmbecker69@gmx.de> - 2013-05-29 15:23 +0200
          Re: Parsing mbox files with Windows Php Christoph Becker <cmbecker69@gmx.de> - 2013-05-29 00:08 +0200

csiph-web