From af57068f0ebb8a95948c56014f693d855d1c7090 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Fri, 11 May 2012 17:32:22 +0300 Subject: [PATCH] [PATCH 1/2] cli: also use Delivered-To header to figure out the reply from address --- 38/eb715d4ce8d8e21bfcab34001d28affa7471d3 | 106 ++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 38/eb715d4ce8d8e21bfcab34001d28affa7471d3 diff --git a/38/eb715d4ce8d8e21bfcab34001d28affa7471d3 b/38/eb715d4ce8d8e21bfcab34001d28affa7471d3 new file mode 100644 index 000000000..45fec5dbf --- /dev/null +++ b/38/eb715d4ce8d8e21bfcab34001d28affa7471d3 @@ -0,0 +1,106 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 67B8D431FB6 + for ; Fri, 11 May 2012 07:32:31 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id tT7uc0KwV-6O for ; + Fri, 11 May 2012 07:32:30 -0700 (PDT) +Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com + [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 8BCB6431FAE + for ; Fri, 11 May 2012 07:32:30 -0700 (PDT) +Received: by lagu2 with SMTP id u2so2102841lag.26 + for ; Fri, 11 May 2012 07:32:28 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; + bh=Do0Mw+ObTyoMuIeoIkEuq5zUtpglWaKhrux4LBGTeHA=; + b=IRIAph6OgaPYFhWfV5kxQdBXFm1tfMVDHxZDMfCKX1G3VFze4gYBOZ54MLXuvG1yRz + g/s9z+PMBpG4NNQ8TlKeR6WG4q6E4Dfbbwo0CI6q3zkPRRb2TolrFZvU6mVkbexNyS/8 + rGZ30JB0dDsamXNL3BtYA1cKhYB4e3WziXkemYf9Uyn1HioQg3RS3iFCvgt+FnwkN6fC + 0oflHkFhVE8jTqftbYHm3CVXklnw28jco05rhHrNLK+K4aEw79hCUuc+Qm7kQUgh46Bu + sRsaK5XiKTS3dxJF1ugqTTIoUi/bs78CF3QUyGZSvVTToX8KJfzKnmB9EuFF9uiIJEDj + 85ow== +Received: by 10.112.42.100 with SMTP id n4mr3753504lbl.90.1336746748724; + Fri, 11 May 2012 07:32:28 -0700 (PDT) +Received: from localhost (dsl-hkibrasgw4-fe50dc00-68.dhcp.inet.fi. + [80.220.80.68]) + by mx.google.com with ESMTPS id j6sm11998180lbl.0.2012.05.11.07.32.25 + (version=SSLv3 cipher=OTHER); Fri, 11 May 2012 07:32:27 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH 1/2] cli: also use Delivered-To header to figure out the reply + from address +Date: Fri, 11 May 2012 17:32:22 +0300 +Message-Id: + <21a946917c5c8dd63295b7c87b7c2d1ebcb6e71e.1336746160.git.jani@nikula.org> +X-Mailer: git-send-email 1.7.9.5 +X-Gm-Message-State: + ALoCoQl5hE+ATABTRFhyIQmbkUblN8+qAW01Gr2GHXl8TcIVd0r7y2/MTFNt/1Fs0f+s8YB+k45H +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 11 May 2012 14:32:31 -0000 + +Add another fallback header Delivered-To for guessing the user's from +address for notmuch reply before using the Received +headers. Apparently some MTAs use Delivered-To instead of +X-Original-To (which already exists as a fallback). + +Reported-by: Michael Hudson-Doyle +Signed-off-by: Jani Nikula +--- + notmuch-reply.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/notmuch-reply.c b/notmuch-reply.c +index 7184a5d..7efd5cd 100644 +--- a/notmuch-reply.c ++++ b/notmuch-reply.c +@@ -334,7 +334,11 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message + const char *delim=". \t"; + size_t i,j,other_len; + +- const char *to_headers[] = {"Envelope-to", "X-Original-To"}; ++ const char *to_headers[] = { ++ "Envelope-to", ++ "X-Original-To", ++ "Delivered-To", ++ }; + + primary = notmuch_config_get_user_primary_email (config); + other = notmuch_config_get_user_other_email (config, &other_len); +@@ -348,8 +352,9 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message + * the To: or Cc: header. From here we try the following in order: + * 1) check for an Envelope-to: header + * 2) check for an X-Original-To: header +- * 3) check for a (for ) clause in Received: headers +- * 4) check for the domain part of known email addresses in the ++ * 3) check for a Delivered-To: header ++ * 4) check for a (for ) clause in Received: headers ++ * 5) check for the domain part of known email addresses in the + * 'by' part of Received headers + * If none of these work, we give up and return NULL + */ +-- +1.7.9.5 + -- 2.26.2