diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2011-05-03 15:37:46 +0200 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2011-05-03 15:37:46 +0200 |
commit | e8c5c8ec32a4e636b7b4fb164bdc999eb63bd504 (patch) | |
tree | 406e5ca532ccf12f5b8476663f5ae5ebf77c5bb6 | |
parent | 81242009035395b10cca2a23a7ba7e85cc6d3d76 (diff) | |
download | fetchmail-e8c5c8ec32a4e636b7b4fb164bdc999eb63bd504.tar.gz fetchmail-e8c5c8ec32a4e636b7b4fb164bdc999eb63bd504.tar.bz2 fetchmail-e8c5c8ec32a4e636b7b4fb164bdc999eb63bd504.zip |
Add FETCHMAIL_IMAP_DELETED_REMAINS_UNSEEN env' var.
Requested by Jonathan Buschmann, to suppress read-notifications on
servers such as MS Exchange or HP OpenMail.
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | fetchmail.man | 8 | ||||
-rw-r--r-- | imap.c | 29 |
3 files changed, 34 insertions, 6 deletions
@@ -64,6 +64,9 @@ fetchmail-6.3.20 (not yet released): * fetchmail now always uses its own MD5 implementation. The library and header variants are too diverse, and we've been bitten before -- and configure complains noisily on Cyrus-SASL's RFC1321 md5.h. +* fetchmail now supports an environment variable to suppress marking deleted + messages as seen at the same time, FETCHMAIL_IMAP_DELETED_REMAINS_UNSEEN. + See the manual page for details. Requested by Jonathan Buschmann. # BUG FIXES * Call strlen() only once when removing CRLF from a line. (Sunil Shetye) diff --git a/fetchmail.man b/fetchmail.man index 903c8d4b..9e136f67 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -2781,6 +2781,14 @@ then that name is used as the default local name. Otherwise session ID (this elaborate logic is designed to handle the case of multiple names per userid gracefully). +.IP \fBFETCHMAIL_IMAP_DELETED_REMAINS_UNSEEN\fP +(since v6.3.20): +If this environment variable is set and not empty, fetchmail will NOT mark +messages retrieved through IMAP as \\Seen as they are deleted. On some servers, +for instance HP OpenMail and MS Exchange, this suppresses delivery +notifications. The default (if this variable is unset or empty) is to mark +messages as \\Seen and \\Deleted at the same time. + .IP \fBFETCHMAIL_INCLUDE_DEFAULT_X509_CA_CERTS\fP (since v6.3.17): If this environment variable is set and not empty, fetchmail will always load @@ -1311,6 +1311,22 @@ static int imap_delete(int sock, struct query *ctl, int number) /* set delete flag for given message */ { int ok; + /* Select which flags to set on message deletion: */ + const char delflags_seen[] = "\\Seen \\Deleted"; + const char delflags_unseen[] = "\\Deleted"; + static const char *delflags; + /* Which environment variable to look for: */ + const char dis_env[] = "FETCHMAIL_IMAP_DELETED_REMAINS_UNSEEN"; + + if (!delflags) { + char *tmp; + if ((tmp = getenv(dis_env)) != NULL && *tmp) { + delflags = delflags_unseen; + } else { + /* DEFAULT since many fetchmail versions <= 6.3.X */ + delflags = delflags_seen; + } + } (void)ctl; /* expunges change the fetch numbers */ @@ -1320,17 +1336,18 @@ static int imap_delete(int sock, struct query *ctl, int number) * Use SILENT if possible as a minor throughput optimization. * Note: this has been dropped from IMAP4rev1. * - * We set Seen because there are some IMAP servers (notably HP - * OpenMail) that do message-receipt DSNs, but only when the seen - * bit is set. This is the appropriate time -- we get here right + * We set \Seen because there are some IMAP servers (notably HP + * OpenMail and MS Exchange) do message-receipt DSNs, + * but only when the seen bit gets set. + * This is the appropriate time -- we get here right * after the local SMTP response that says delivery was * successful. */ if ((ok = gen_transact(sock, imap_version == IMAP4 - ? "STORE %d +FLAGS.SILENT (\\Seen \\Deleted)" - : "STORE %d +FLAGS (\\Seen \\Deleted)", - number))) + ? "STORE %d +FLAGS.SILENT (%s)" + : "STORE %d +FLAGS (%s)", + number, delflags))) return(ok); else deletions++; |