From c9121f9ba674c375f0cf6eb874e907a8bca9d7ac Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Thu, 24 May 2012 08:15:49 +0300 Subject: [PATCH] [PATCH v2 1/2] cli: also use Delivered-To header to figure out the reply from address --- 7b/c81a21157a93cd7ece73f7d2b06abce25f5d6b | 112 ++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 7b/c81a21157a93cd7ece73f7d2b06abce25f5d6b diff --git a/7b/c81a21157a93cd7ece73f7d2b06abce25f5d6b b/7b/c81a21157a93cd7ece73f7d2b06abce25f5d6b new file mode 100644 index 000000000..053a4725e --- /dev/null +++ b/7b/c81a21157a93cd7ece73f7d2b06abce25f5d6b @@ -0,0 +1,112 @@ +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 60864431FC4 + for ; Wed, 23 May 2012 22:15:58 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +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 LtC102gNK2BL for ; + Wed, 23 May 2012 22:15:57 -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 505C1431FCB + for ; Wed, 23 May 2012 22:15:57 -0700 (PDT) +Received: by mail-lpp01m010-f53.google.com with SMTP id u2so6544458lag.26 + for ; Wed, 23 May 2012 22:15:57 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=from:to:subject:date:message-id:x-mailer:in-reply-to:references + :in-reply-to:references:x-gm-message-state; + bh=nylrmk7S/AtggMxVo1srfVLB3InySZ4Jb2tIuxC/CXQ=; + b=ftJkeyuLixJYaXa8ii5ZSWZjn2N8P4yoBVyGq/2dB+2lKKA/58j3iHXyV/PWj4hWdd + JCw/8FR48pjP9WjKzS8Mw/Mjgv3OhvYc6DjmVjdaiX10uBpCc9qYav/zpw0e4ZbpkcX/ + SqKoSJBJ3wLUrGR+2WcF0A1DmVWYeQ4WkwCBDPJLPiuS3yi2nU7425C7RXDi+NBUzfKl + EgF7jsG/0yTnCNNvKzGv5z67LigKAX39reX6oODciz3dKqWqK2w8ApLy7NCpmReDbPsC + 5rdSfqwoelHSqBVpwpIbaDgh76L0V7+jsesxVGwg9cV81Fj5y+9+g46rKD03+Nd0cocR + wBXQ== +Received: by 10.152.123.244 with SMTP id md20mr29734624lab.0.1337836556872; + Wed, 23 May 2012 22:15:56 -0700 (PDT) +Received: from localhost (dsl-hkibrasgw4-fe50dc00-68.dhcp.inet.fi. + [80.220.80.68]) + by mx.google.com with ESMTPS id tt8sm578444lbb.16.2012.05.23.22.15.55 + (version=SSLv3 cipher=OTHER); Wed, 23 May 2012 22:15:56 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH v2 1/2] cli: also use Delivered-To header to figure out the + reply from address +Date: Thu, 24 May 2012 08:15:49 +0300 +Message-Id: + <486cc9d33e43f3afba4bcdab71a489a36e453893.1337836150.git.jani@nikula.org> +X-Mailer: git-send-email 1.7.9.5 +In-Reply-To: +References: +In-Reply-To: +References: +X-Gm-Message-State: + ALoCoQnzOUBW1EQd4DVxo/jfsE+a1Obl5cH6R4r6PkN0JBkWZ52NTgEaxfcWKu/ASSXaKaaST9J/ +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: Thu, 24 May 2012 05:15:58 -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 51cb6de..0f92a2e 100644 +--- a/notmuch-reply.c ++++ b/notmuch-reply.c +@@ -384,7 +384,11 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message + const char *delim=". \t"; + size_t i; + +- const char *to_headers[] = {"Envelope-to", "X-Original-To"}; ++ const char *to_headers[] = { ++ "Envelope-to", ++ "X-Original-To", ++ "Delivered-To", ++ }; + + /* sadly, there is no standard way to find out to which email + * address a mail was delivered - what is in the headers depends +@@ -395,8 +399,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