Re: Wrong detection of new mails

From: Joey Schulze <>
Date: Sun, 29 Jul 2007 20:03:44 +0200

Pavel Sanda wrote:
> i recently updated to newmail 0.4. and it has unfortunately
> one bug, which the very old version i used before had not.
> the problem is that newmail signals new mail even in case
> that i only reply to some other mail and also in other cases
> when changing flags of the mails.
> i found the reason of the bug (which is the same as two years-back report on list):
> newmail detects changes on mailbox only by means of filesize.
> if it detects change, it seeks to the last scanned position in the file
> and scans from this position to newly arrived messages.
> the problem happens in the moment, when email reader makes some
> change on mailbox which in fact makes the files bigger - as flagging
> some messages as replied etc. newmail detects bigger file, seeks
> into some weird position inside (usually) last message, scans its
> body, dont find header info and emit " - " message to console.

I now understand the problem and can reproduce it. Never saw it because
I didn't sync any active mailboxes in the middle of processing.

> attached oneliner patch just test emptiness of emitted message,
> which wont be written to console in such a case.
> drawbacks are clear:
> a) we dont get info about messages which dont have name and subject in header
> b) if there are much more messages somewhat flagged by mail client, newmail
> will seek before message(s) at the end and detect wrongly old message(s) as new.

I've improved the patch a little bit to look like what is attached.

When a mail does not have a From: and not a From_ header it can safely
be assumed that it is no real mail, thus no information should be written.

Assuming the header is 20 lines long, the mail 10 lines, then after
replying to 15 or 30 mails and syncing the mailbox newmail will
potentially read the mailbox again and may report the last mail a
second time.

To avoid this, we'd need a msgid buffer or something similar which
would increase the complexity and size of newmail. I could accept
to save the last name+subject/msgid and check against this before
reporting a new mail, however, duplicate mail wouldn't be recognised
then. I'd rather leave the code with the attached patch.

> i tried to look on old versions of newmail, which i used and which didnt have this
> bug and to my surpise its seems to be quite different code. heh :)

This is "documented" here:



The good thing about standards is that there are so many to choose from.
		-- Andrew S. Tanenbaum
Received on Sun Jul 29 2007 - 20:03:44 CEST

This archive was generated by hypermail 2.2.0 : Sun Jul 29 2007 - 20:07:10 CEST