Discussion:
Configuring getmail to delete messages or read only new
Erik Myllymaki
2009-08-20 23:25:44 UTC
Permalink
Hello,

I am trying to configure getmail to only read new, or even delete read
messages on the IMAP server (Cyrus IMAP .

I have added:

[options]

delete = True
read_all = False

as well as used the command line options -n and -d but the messages are
still sticking on my IMAP server and being downloaded over and over by
getmail.

I used the --trace options and I do see the following lines:

overriding option read_all from commandline False
overriding option delete from commandline True

So I know that much is working.

I was using v4.7.7 which aptitude got on Ubuntu 8.04.3 but I got the
latest 4.11 version just now and the result is the same.

Everything else is working well, except for deleting (or not downloading
twice) the same message again and again.

thanks for any tips.
Stephen Allen
2009-08-20 23:50:02 UTC
Permalink
Hi Erik,

I'm only a new user to getmail so please forgive me if my answer is a
bit basic - but at least I'm trying to take the load off Charles ;)

The getmail documentation for the 'delete' option says: "will delete
messages after retrieving and successfully delivering them". Are you
sure they're being successfully delivered?

Likewise for the 'read_all' option, getmail may consider messages that
are not successfully delivered, as "unseen" when it performs its next check.

Regards,
Steve
Post by Erik Myllymaki
Hello,
I am trying to configure getmail to only read new, or even delete read
messages on the IMAP server (Cyrus IMAP .
[options]
delete = True
read_all = False
as well as used the command line options -n and -d but the messages are
still sticking on my IMAP server and being downloaded over and over by
getmail.
overriding option read_all from commandline False
overriding option delete from commandline True
So I know that much is working.
I was using v4.7.7 which aptitude got on Ubuntu 8.04.3 but I got the
latest 4.11 version just now and the result is the same.
Everything else is working well, except for deleting (or not downloading
twice) the same message again and again.
thanks for any tips.
---------------------------------------------------------------------
Erik Myllymaki
2009-08-21 00:22:25 UTC
Permalink
Post by Stephen Allen
Hi Erik,
I'm only a new user to getmail so please forgive me if my answer is a
bit basic - but at least I'm trying to take the load off Charles ;)
The getmail documentation for the 'delete' option says: "will delete
messages after retrieving and successfully delivering them". Are you
sure they're being successfully delivered?
Likewise for the 'read_all' option, getmail may consider messages that
are not successfully delivered, as "unseen" when it performs its next check.
there are being delivered, yes.

I am using getmail to pickup mail from inboxes where the email is
destined for OpenERP.

I use the MDA_external destination type and it calls a python script
which populates the
Database.

But your question made me think of how this script is signaling success,
so I just turned the ignore_stderr option on and it is now deleting the
messages properly.

Thanks - a step in the right direction anyway.
Charles Cazabon
2009-08-21 04:21:55 UTC
Permalink
Post by Erik Myllymaki
Post by Stephen Allen
I'm only a new user to getmail so please forgive me if my answer is a
bit basic - but at least I'm trying to take the load off Charles ;)
And I appreciate it.
Post by Erik Myllymaki
Post by Stephen Allen
The getmail documentation for the 'delete' option says: "will delete
messages after retrieving and successfully delivering them". Are you
sure they're being successfully delivered?
But your question made me think of how this script is signaling success,
so I just turned the ignore_stderr option on and it is now deleting the
messages properly.
I'm glad Stephen put you on the right track. Yes, if getmail thinks the
message wasn't successfully delivered, it will not delete the message from the
server or consider it "read", as getmail tries very hard not to lose or
destroy your mail.

There's several things that can cause getmail to think the delivery failed
with an MDA_external:

* mda exits nonzero
* mda writes to stderr (overridable, as you found)
* a failed filter before invoking the mda

If you're writing your own MDA (as you said, to deliver to a database), you
have to be careful to prevent mail being lost -- in the case of the mda being
unable to guarantee the mail is preserved, it absolutely must exit nonzero to
ensure getmail knows to preserve that message. The stderr bit is merely extra
caution on getmail's part; some mdas can exit zero even when failing to
deliver mail properly (procmail is famous for it).

Charles
--
-----------------------------------------------------------------------
Charles Cazabon
GPL'ed software available at: http://pyropus.ca/software/
-----------------------------------------------------------------------
Loading...