]> Pileus Git - ~andy/fetchmail/commitdiff
Make "envelope 'Delivered-To'" work with dropdelivered. Timothy Lee.
authorMatthias Andree <matthias.andree@gmx.de>
Fri, 23 Sep 2005 23:32:29 +0000 (23:32 -0000)
committerMatthias Andree <matthias.andree@gmx.de>
Fri, 23 Sep 2005 23:32:29 +0000 (23:32 -0000)
svn path=/trunk/; revision=4319

NEWS
transact.c

diff --git a/NEWS b/NEWS
index 472a5236564d194becafadc589ea84a1e99f5d7a..9845c176a120d2629a86fd23572a7f4e8996c8db 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -211,6 +211,7 @@ fetchmail 6.3.0 (not yet released officially):
   Thomas Wolff. Matthias Andree.
 * Kerberos IV detection fix for FreeBSD 4. Simon Barner. (MA)
 * Fix display and documentation of --envelope option. Matthias Andree
+* Make "envelope 'Delivered-To'" work with dropdelivered. Timothy Lee. (MA)
 
 # INTERNAL CHANGES
 * Switched to automake. Matthias Andree.
@@ -254,7 +255,7 @@ fetchmail-6.2.3 (Thu Jul 17 14:53:00 EDT 2003), 22490 lines:
 * Brian Sammon's patch to deal with malformed message lines containing NULs.
 * Fai's patch to ignore all but the first Return-Path (some spams have
   more than one of these).
-* Benjamin Drieu's patch to properly byte-stuff when talking to BSNTP.
+* Benjamin Drieu's patch to properly byte-stuff when talking to BSMTP.
   Fixes Debian bug #184469.
 * Benjamin Drieu's patch to enable auth=cram-md5.
   Fixes Debian bug #185232.
index 7c348f3ddafe72a5c88e691d3e31565cf9e4bbd7..136e7b6927bb30a8d63229dfedfaaee43543ff2c 100644 (file)
@@ -379,6 +379,7 @@ int readheaders(int sock,
     static char                *delivered_to = NULL;
     int                n, oldlen, ch, remaining, skipcount;
     size_t             linelen;
+    int                        delivered_to_count;
     struct idlist      *idp;
     flag               no_local_matches = FALSE;
     flag               has_nuls;
@@ -415,6 +416,7 @@ int readheaders(int sock,
     oldlen = 0;
     msgblk.msglen = 0;
     skipcount = 0;
+    delivered_to_count = 0;
     ctl->mimemsg = 0;
 
     for (remaining = fetchlen; remaining > 0 || protocol->delimited; )
@@ -653,17 +655,24 @@ int readheaders(int sock,
        }
 
        /*
-        * We remove all Delivered-To: headers.
-        * 
-        * This is to avoid false mail loops messages when delivering
-        * local messages to and from a Postfix/qmail mailserver. 
+        * We remove all Delivered-To: headers if dropdelivered is set
+        * - special care must be taken if Delivered-To: is also used
+        * as envelope at the same time.
+        *
+        * This is to avoid false mail loops errors when delivering
+        * local messages to and from a Postfix or qmail mailserver.
         */
        if (ctl->dropdelivered && !strncasecmp(line, "Delivered-To:", 13)) 
        {
-           if (delivered_to)
+           if (delivered_to ||
+               ctl->server.envelope == STRING_DISABLED ||
+               !ctl->server.envelope ||
+               strcasecmp(ctl->server.envelope, "Delivered-To") ||
+               delivered_to_count != ctl->server.envskip)
                free(line);
            else 
                delivered_to = line;
+           delivered_to_count++;
            continue;
        }