Subject: Status: O

From: "Tomas Pospisek's Mailing Lists" <[email-masked]>
Date: Tue, 24 Sep 2002 01:10:58 +0200 (CEST)

I'm trying to sync mail from an IMAP server to a /var/spool/mail/mbox [1].
The problem is, that mail_append[_full] will allways add a

	Status: O

to the mail, even if I pass an empty string to the function as "flags".

The problem with this is that the mutt MUA interprets Status: O as an old
message, that is != New message, which means that I'm unable to sync with
an IMAP server in a way that will enable mutt to see new messages. I
think mutt's behaveour is in accordance with RFC2076 which states that:

	O    message is old but not deleted.

That RFC also states that:

	N    new (a new message also sometimes is distinguished
             by not having any "Status:" header.

If I could achieve either of:

* append a message with "Status: " without any flags

* append a message without a "Status:" header at all

* append a message with the flag "N" as in "Status: N"

then I'd be done, but it doesn't seem that c-client can do any of those
(?). If there is a way to achieve that I'd be glad if I could be pointed
to the relevant source/docu. Otherwise I'd like to know if such
functionality could be added to c-client?

*t

[1] mailsync.sf.net

--
-----------------------------------------------------------
         Tomas Pospisek
         SourcePole   -  Linux & Open Source Solutions
         http://sourcepole.ch
         Elestastrasse 18, 7310 Bad Ragaz, Switzerland
         Tel: +41 (81) 330 77 11
-----------------------------------------------------------

-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Mark Crispin <[email-masked]>
Date: Mon, 23 Sep 2002 19:52:07 -0700 (PDT)

On Tue, 24 Sep 2002 01:10:58 +0200 (CEST), Tomas Pospisek's Mailing Lists
> to the mail, even if I pass an empty string to the function as "flags".

What version of c-client are you using?  No current version of c-client does
that, and it looks like this was changed way back in imap-4.1 days, between 5
and 6 years ago.

If you are using a modern c-client, then mail_append_full() does not set "O"
status, and something else must be doing it.  If you have the mailbox open
when you do the append, then that "something else" is the open mail stream.

---

From: tomas pospisek <[email-masked]>
Date: Tue, 24 Sep 2002 11:19:13 +0200 (CEST)

> that, and it looks like this was changed way back in imap-4.1 days, between 5

I'm using the version from 2001 (the one currently packaged in Debian),
but I've also compiled and tested against the current one RC5, with the
same result.

> when you do the append, then that "something else" is the open mail stream.

Oh. OK, I'll check the programm and make sure it's not appending while it
has the box open.

Is there a specific reason appending to an open stream will automatically
mark the appenden messages "Status: O"?

Thanks,
*t

--
  to
    ma
      s
        p

---

From: tomas pospisek <[email-masked]>
Date: Tue, 24 Sep 2002 12:10:32 +0200 (CEST)

> Oh. OK, I'll check the programm and make sure it's not appending while it

Let me see, if I understand this right. mail_append_full has the following
syntax:

long mail_append_full (MAILSTREAM *stream,char *mailbox,char *flags,
                       char *date, STRING *message);

Are you saying that I should be appending to a _closed_ stream?

Btw - I note that pine apparently falls into the same pithole as me, since
if I write a message to myself from within pine it gets "Status: O",
even before I even see it in the index.

*t

--
  to
    ma
      s
        p

---

From: Mark Crispin <[email-masked]>
Date: Tue, 24 Sep 2002 07:41:23 -0700 (PDT)

> mark the appenden messages "Status: O"?

If the stream is open on the mailbox being appended to, then when you append
to that mailbox, the open stream will see the new message.  The open stream
will call the new message \Recent, and set "Status: O" in the file for
subsequent streams.

> Are you saying that I should be appending to a _closed_ stream?

You can append to a null stream, or to a stream open on another mailbox.  Note
that a closed stream (mail_close() called on it) is no longer valid and has
been free()d.

In general, you only should provide a non-null stream if you are using IMAP,
and already have a stream open to the IMAP server for the APPEND destination
mailbox.  In that case, c-client will use that stream instead of making a
temporary stream.

The other reason to provide a non-null stream is for setting local formats,
but that's a power tool.

> even before I even see it in the index.

I just tested it in Pine.  I saved a message to a new mailbox.  It did not get
the "Status: O" flag.

---

From: [email-masked]
Date: Tue, 24 Sep 2002 22:14:06 +0200

Quoting Mark Crispin <[email-masked]>:

> You can append to a null stream, or to a stream open on another mailbox. 
> Note that a closed stream (mail_close() called on it) is no longer valid and
> has been free()d.
> 
> In general, you only should provide a non-null stream if you are using
> IMAP, and already have a stream open to the IMAP server for the APPEND
> destination mailbox.  In that case, c-client will use that stream instead of
> making a temporary stream.

OK, thanks a lot. I can provide you a patch against the docu to have that 
documented there. Are you interested?

And if I append a message to an open IMAP stream than the same will happen, 
the mail will recieve the "Status: O" flag or not? Because when syncing I don't
want to bother the user with re-entering the password. I want to be able to ask
him/her once and then to sync.

> > Btw - I note that pine apparently falls into the same pithole as me,
> > since if I write a message to myself from within pine it gets "Status: O",
> I just tested it in Pine.  I saved a message to a new mailbox.  It did not
> get the "Status: O" flag.

Um - I'm in my local INBOX and I send mail (through the normal MTA (=exim)) 
locally to myself (tpo@localhost). I won't see the message since I don't press
cursor down at the bottom of the INBOX page. Next I quit pine and have a look
through an editor at my /var/spool/mail/tpo inbox. And I see that "Status: O"
is set there.

*t

-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

---

From: Mark Crispin <[email-masked]>
Date: Tue, 24 Sep 2002 13:42:57 -0700 (Pacific Daylight Time)

On Tue, 24 Sep 2002 [email-masked] wrote:
> And if I append a message to an open IMAP stream than the same will
> happen, the mail will recieve the "Status: O" flag or not?

If you append a message to a mailbox *while that mailbox is open*, then
the entity that has that mailbox open will see the newly-appended message
as \Recent and set "Status: O".

An open IMAP stream on some other mailbox will not set "Status: O", even
if you use it as the argument to mail_append().

An open IMAP stream on no mailbox (a "half-open" stream) will not set
"Status: O", even if you use it as the argument to mail_append().

An open IMAP stream on that mailbox will set "Status: O", even if you do
not use it as the argument to mail_append().

An open IMAP or POP3 stream on that mailbox by some other client will set
"Status: O", as will an open local mailbox stream.

> Because when
> syncing I don't want to bother the user with re-entering the password. I
> want to be able to ask him/her once and then to sync.

Most clients cache authentication credentials to use in subsequent
authentications, to avoid the "bother the user with re-entering the
password" problem.

> through an editor at my /var/spool/mail/tpo inbox. And I see that "Status: O"

That is because Pine saw the message!

You quit Pine before the Pine user interface showed you the message.
However, the act of quitting Pine causes Pine to do a final
synchronization with the mailbox.  That final syncronization caused Pine
to see the message.

If you append to a mailbox while something, somewhere, has the mailbox
open, you can not expect that hurriedly quitting that "something" will
prevent that "something" from seeing the message and setting "Status: O".

You MUST assume that if something, somewhere, has the mailbox open, then
that "something" WILL see the message and WILL set "Status: O".

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.