[imapfilter-devel] is_new()

David DeSimone fox at verio.net
Thu Jan 10 11:52:27 EET 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tulsidhar Dronamraju <tulasidhard at yahoo.co.in> wrote:
>
> I use is_new() to search and list me mails that have come since the
> last time I ran imapfilter.  However I have this mailbox opened in
> parallel by some-other mail-client.  Imapfilter seems to return 0 new
> mails everytime. 

The IMAP specification says that 'New' messages mean "never presented to
any mail client before."  Once a client has been informed that a message
exists, the message is no longer considered 'New' anymore.  If you have
two clients connected to a mailbox simultaneously, only one of them will
be informed of 'New' messages, and it depends on the timing, most likely
whichever client polls or performs mailbox commands more frequently.

Since imapfilter (in daemon mode) spends a lot of time just sitting and
waiting, it is unlikely that it will be the client presented information
about new messages.  The other client, which presumably is actively
scanning for new mail, or that you are reading messages with, is the
more likely client to be informed.

> Using the other mail-client shows that there are mails that have
> arrived.  All the mails in the mailbox are marked unread.  Is this
> expected behaviour from is_new()?

If you understand the IMAP spec, it is expected.  Imapfilter does not
have any special magic; it only informs you of what the IMAP server has
told it about your messages.

This is a stumbling block I have run into as well.  There is no "good"
way to figure out which messages in a folder have been seen and
processed already.  My solution involved moving the messages out of the
folder and into a subfolder, when they were processed.  This would
prevent the messages from being checked twice, but I am not terribly
happy with that solution.

The only other method that comes to mind (and this is the method that I
believe most IMAP mail readers use) is to simply record the UID's of
messages found in a mailbox, so that if you compare it to the list of
UID's later found to be in the mailbox, you can tell which messages have
never been seen before.  This of course requires storing a database
outside of IMAP, which is cumbersome and could be error-prone as well.

- -- 
David DeSimone == Network Admin == fox at verio.net
"This email message is intended for the use of the person to whom
 it has been sent, and may contain information that is confidential
 or legally protected.  If you are not the intended recipient or have
 received this message in error, you are not authorized to copy, dis-
 tribute, or otherwise use this message or its attachments.  Please
 notify the sender immediately by return e-mail and permanently delete
 this message and any attachments.  Verio, Inc. makes no warranty that
 this email is error or virus free.  Thank you."  --Lawyer Bot 6000
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFHheraFSrKRjX5eCoRAmriAJ47cjhqSnvf9Lpik8YtfSHq9L3yCgCgp0Wa
2hLt3kkoFEVBoee14TQzAQo=
=s1yZ
-----END PGP SIGNATURE-----




More information about the Imapfilter-devel mailing list