[PATCH 1/2] cli: also use Delivered-To header to figure out the reply from address
[notmuch-archives.git] / 38 / eb715d4ce8d8e21bfcab34001d28affa7471d3
1 Return-Path: <jani@nikula.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 67B8D431FB6\r
6         for <notmuch@notmuchmail.org>; Fri, 11 May 2012 07:32:31 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id tT7uc0KwV-6O for <notmuch@notmuchmail.org>;\r
16         Fri, 11 May 2012 07:32:30 -0700 (PDT)\r
17 Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com\r
18         [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 8BCB6431FAE\r
21         for <notmuch@notmuchmail.org>; Fri, 11 May 2012 07:32:30 -0700 (PDT)\r
22 Received: by lagu2 with SMTP id u2so2102841lag.26\r
23         for <notmuch@notmuchmail.org>; Fri, 11 May 2012 07:32:28 -0700 (PDT)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=google.com; s=20120113;\r
26         h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state;\r
27         bh=Do0Mw+ObTyoMuIeoIkEuq5zUtpglWaKhrux4LBGTeHA=;\r
28         b=IRIAph6OgaPYFhWfV5kxQdBXFm1tfMVDHxZDMfCKX1G3VFze4gYBOZ54MLXuvG1yRz\r
29         g/s9z+PMBpG4NNQ8TlKeR6WG4q6E4Dfbbwo0CI6q3zkPRRb2TolrFZvU6mVkbexNyS/8\r
30         rGZ30JB0dDsamXNL3BtYA1cKhYB4e3WziXkemYf9Uyn1HioQg3RS3iFCvgt+FnwkN6fC\r
31         0oflHkFhVE8jTqftbYHm3CVXklnw28jco05rhHrNLK+K4aEw79hCUuc+Qm7kQUgh46Bu\r
32         sRsaK5XiKTS3dxJF1ugqTTIoUi/bs78CF3QUyGZSvVTToX8KJfzKnmB9EuFF9uiIJEDj\r
33         85ow==\r
34 Received: by 10.112.42.100 with SMTP id n4mr3753504lbl.90.1336746748724;\r
35         Fri, 11 May 2012 07:32:28 -0700 (PDT)\r
36 Received: from localhost (dsl-hkibrasgw4-fe50dc00-68.dhcp.inet.fi.\r
37         [80.220.80.68])\r
38         by mx.google.com with ESMTPS id j6sm11998180lbl.0.2012.05.11.07.32.25\r
39         (version=SSLv3 cipher=OTHER); Fri, 11 May 2012 07:32:27 -0700 (PDT)\r
40 From: Jani Nikula <jani@nikula.org>\r
41 To: notmuch@notmuchmail.org\r
42 Subject: [PATCH 1/2] cli: also use Delivered-To header to figure out the reply\r
43         from address\r
44 Date: Fri, 11 May 2012 17:32:22 +0300\r
45 Message-Id:\r
46  <21a946917c5c8dd63295b7c87b7c2d1ebcb6e71e.1336746160.git.jani@nikula.org>\r
47 X-Mailer: git-send-email 1.7.9.5\r
48 X-Gm-Message-State:\r
49  ALoCoQl5hE+ATABTRFhyIQmbkUblN8+qAW01Gr2GHXl8TcIVd0r7y2/MTFNt/1Fs0f+s8YB+k45H\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Fri, 11 May 2012 14:32:31 -0000\r
63 \r
64 Add another fallback header Delivered-To for guessing the user's from\r
65 address for notmuch reply before using the Received\r
66 headers. Apparently some MTAs use Delivered-To instead of\r
67 X-Original-To (which already exists as a fallback).\r
68 \r
69 Reported-by: Michael Hudson-Doyle <michael.hudson@canonical.com>\r
70 Signed-off-by: Jani Nikula <jani@nikula.org>\r
71 ---\r
72  notmuch-reply.c |   11 ++++++++---\r
73  1 file changed, 8 insertions(+), 3 deletions(-)\r
74 \r
75 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
76 index 7184a5d..7efd5cd 100644\r
77 --- a/notmuch-reply.c\r
78 +++ b/notmuch-reply.c\r
79 @@ -334,7 +334,11 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message\r
80      const char *delim=". \t";\r
81      size_t i,j,other_len;\r
82  \r
83 -    const char *to_headers[] = {"Envelope-to", "X-Original-To"};\r
84 +    const char *to_headers[] = {\r
85 +       "Envelope-to",\r
86 +       "X-Original-To",\r
87 +       "Delivered-To",\r
88 +    };\r
89  \r
90      primary = notmuch_config_get_user_primary_email (config);\r
91      other = notmuch_config_get_user_other_email (config, &other_len);\r
92 @@ -348,8 +352,9 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message\r
93       * the To: or Cc: header. From here we try the following in order:\r
94       * 1) check for an Envelope-to: header\r
95       * 2) check for an X-Original-To: header\r
96 -     * 3) check for a (for <email@add.res>) clause in Received: headers\r
97 -     * 4) check for the domain part of known email addresses in the\r
98 +     * 3) check for a Delivered-To: header\r
99 +     * 4) check for a (for <email@add.res>) clause in Received: headers\r
100 +     * 5) check for the domain part of known email addresses in the\r
101       *    'by' part of Received headers\r
102       * If none of these work, we give up and return NULL\r
103       */\r
104 -- \r
105 1.7.9.5\r
106 \r