unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/2] cli: also use Delivered-To header to figure out the reply from address
@ 2012-05-11 14:32 Jani Nikula
  2012-05-11 14:32 ` [PATCH 2/2] test: add tests for notmuch reply From guessing Jani Nikula
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jani Nikula @ 2012-05-11 14:32 UTC (permalink / raw)
  To: notmuch

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 <michael.hudson@canonical.com>
Signed-off-by: Jani Nikula <jani@nikula.org>
---
 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 <email@add.res>) 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 <email@add.res>) 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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] test: add tests for notmuch reply From guessing
  2012-05-11 14:32 [PATCH 1/2] cli: also use Delivered-To header to figure out the reply from address Jani Nikula
@ 2012-05-11 14:32 ` Jani Nikula
  2012-05-11 20:17 ` [PATCH 1/2] cli: also use Delivered-To header to figure out the reply from address Tomi Ollila
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2012-05-11 14:32 UTC (permalink / raw)
  To: notmuch

Add tests for picking up user's From address from fallback headers
Envelope-To, X-Original-To, and Delivered-To.

Signed-off-by: Jani Nikula <jani@nikula.org>
---
 test/reply |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/test/reply b/test/reply
index 00f4bea..ee5d361 100755
--- a/test/reply
+++ b/test/reply
@@ -138,4 +138,59 @@ References: <${gen_msg_id}>
 
 On Tue, 05 Jan 2010 15:43:56 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
 > 200-byte header"
+
+test_begin_subtest "From guessing: Envelope-To"
+add_message '[from]="Sender <sender@example.com>"' \
+	    '[to]="Recipient <recipient@example.com>"' \
+	    '[subject]="From guessing"' \
+	    '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
+	    '[body]="From guessing"' \
+	    '[header]="Envelope-To: test_suite_other@notmuchmail.org"'
+
+output=$(notmuch reply id:${gen_msg_id})
+test_expect_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
+Subject: Re: From guessing
+To: Sender <sender@example.com>, Recipient <recipient@example.com>
+In-Reply-To: <${gen_msg_id}>
+References: <${gen_msg_id}>
+
+On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
+> From guessing"
+
+test_begin_subtest "From guessing: X-Original-To"
+add_message '[from]="Sender <sender@example.com>"' \
+	    '[to]="Recipient <recipient@example.com>"' \
+	    '[subject]="From guessing"' \
+	    '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
+	    '[body]="From guessing"' \
+	    '[header]="X-Original-To: test_suite@otherdomain.org"'
+
+output=$(notmuch reply id:${gen_msg_id})
+test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@otherdomain.org>
+Subject: Re: From guessing
+To: Sender <sender@example.com>, Recipient <recipient@example.com>
+In-Reply-To: <${gen_msg_id}>
+References: <${gen_msg_id}>
+
+On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
+> From guessing"
+
+test_begin_subtest "From guessing: Delivered-To"
+add_message '[from]="Sender <sender@example.com>"' \
+	    '[to]="Recipient <recipient@example.com>"' \
+	    '[subject]="From guessing"' \
+	    '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
+	    '[body]="From guessing"' \
+	    '[header]="Delivered-To: test_suite_other@notmuchmail.org"'
+
+output=$(notmuch reply id:${gen_msg_id})
+test_expect_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
+Subject: Re: From guessing
+To: Sender <sender@example.com>, Recipient <recipient@example.com>
+In-Reply-To: <${gen_msg_id}>
+References: <${gen_msg_id}>
+
+On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
+> From guessing"
+
 test_done
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] cli: also use Delivered-To header to figure out the reply from address
  2012-05-11 14:32 [PATCH 1/2] cli: also use Delivered-To header to figure out the reply from address Jani Nikula
  2012-05-11 14:32 ` [PATCH 2/2] test: add tests for notmuch reply From guessing Jani Nikula
@ 2012-05-11 20:17 ` Tomi Ollila
  2012-05-12 14:11 ` Mark Walters
  2012-05-14  2:15 ` Michael Hudson-Doyle
  3 siblings, 0 replies; 5+ messages in thread
From: Tomi Ollila @ 2012-05-11 20:17 UTC (permalink / raw)
  To: Jani Nikula, notmuch

On Fri, May 11 2012, Jani Nikula <jani@nikula.org> wrote:

> 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 <michael.hudson@canonical.com>
> Signed-off-by: Jani Nikula <jani@nikula.org>
> ---

LGTM -- both patches -- "All 437 tests passed."

Tomi

>  notmuch-reply.c |   11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] cli: also use Delivered-To header to figure out the reply from address
  2012-05-11 14:32 [PATCH 1/2] cli: also use Delivered-To header to figure out the reply from address Jani Nikula
  2012-05-11 14:32 ` [PATCH 2/2] test: add tests for notmuch reply From guessing Jani Nikula
  2012-05-11 20:17 ` [PATCH 1/2] cli: also use Delivered-To header to figure out the reply from address Tomi Ollila
@ 2012-05-12 14:11 ` Mark Walters
  2012-05-14  2:15 ` Michael Hudson-Doyle
  3 siblings, 0 replies; 5+ messages in thread
From: Mark Walters @ 2012-05-12 14:11 UTC (permalink / raw)
  To: Jani Nikula, notmuch


On Fri, 11 May 2012, Jani Nikula <jani@nikula.org> wrote:
> 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 <michael.hudson@canonical.com>
> Signed-off-by: Jani Nikula <jani@nikula.org>

This pair of patches looks good to me. +1

Best wishes

Mark

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] cli: also use Delivered-To header to figure out the reply from address
  2012-05-11 14:32 [PATCH 1/2] cli: also use Delivered-To header to figure out the reply from address Jani Nikula
                   ` (2 preceding siblings ...)
  2012-05-12 14:11 ` Mark Walters
@ 2012-05-14  2:15 ` Michael Hudson-Doyle
  3 siblings, 0 replies; 5+ messages in thread
From: Michael Hudson-Doyle @ 2012-05-14  2:15 UTC (permalink / raw)
  To: Jani Nikula, notmuch

Jani Nikula <jani@nikula.org> writes:

> 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 <michael.hudson@canonical.com>
> Signed-off-by: Jani Nikula <jani@nikula.org>

Firstly, thank you so much for doing this!

Unfortunately it doesn't work for me :( Poking around a bit reveals why:
I have two Delivered-To: headers in the problem mails, and only the
lower/earlier one containst the email address I want to be used as
From:.  And it seems that the only header one can get all values for is
Received...

Cheers,
mwh

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-14  2:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-11 14:32 [PATCH 1/2] cli: also use Delivered-To header to figure out the reply from address Jani Nikula
2012-05-11 14:32 ` [PATCH 2/2] test: add tests for notmuch reply From guessing Jani Nikula
2012-05-11 20:17 ` [PATCH 1/2] cli: also use Delivered-To header to figure out the reply from address Tomi Ollila
2012-05-12 14:11 ` Mark Walters
2012-05-14  2:15 ` Michael Hudson-Doyle

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).