unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] lib: consider all instances of Delivered-To header
@ 2021-06-23 10:29 Hannu Hartikainen
  2021-06-23 10:58 ` Michael J Gruber
  2021-06-26 17:36 ` David Bremner
  0 siblings, 2 replies; 8+ messages in thread
From: Hannu Hartikainen @ 2021-06-23 10:29 UTC (permalink / raw)
  To: notmuch; +Cc: Hannu Hartikainen

When using notmuch-reply and guessing the From: address from
Delivered-To headers, I had the wrong address chosen today. This was
because the messages from the notmuch list contain these headers in this
order:

Delivered-To: hannu.hartikainen@gmail.com
...
Delivered-To: hannu@hrtk.in

In my .notmuch-config I have the following configuration:

primary_email=hannu@hrtk.in
other_email=hannu.hartikainen@gmail.com;...

Before this change, notmuch-reply would guess From: @gmail.com because
that is the first Delivered-To header present. After the change, the
primary address is chosen as I would expect.
---
 lib/message-file.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/message-file.c b/lib/message-file.c
index 647ccf3a..7e8ea09c 100644
--- a/lib/message-file.c
+++ b/lib/message-file.c
@@ -291,11 +291,15 @@ _notmuch_message_file_get_header (notmuch_message_file_t *message,
     if (value)
 	return value;
 
-    if (strcasecmp (header, "received") == 0) {
+    if (strcasecmp (header, "received") == 0 ||
+            strcasecmp (header, "delivered-to") == 0) {
 	/*
-	 * The Received: header is special. We concatenate all
-	 * instances of the header as we use this when analyzing the
-	 * path the mail has taken from sender to recipient.
+	 * The Received: header is special. We concatenate all instances of the
+	 * header as we use this when analyzing the path the mail has taken
+	 * from sender to recipient.
+	 *
+	 * Similarly, multiple instances of Delivered-To may be present. We
+	 * concatenate them so the one with highest priority may be picked.
 	 */
 	decoded = _notmuch_message_file_get_combined_header (message, header);
     } else {
-- 
2.32.0

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

end of thread, other threads:[~2021-08-30  1:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-23 10:29 [PATCH] lib: consider all instances of Delivered-To header Hannu Hartikainen
2021-06-23 10:58 ` Michael J Gruber
2021-06-23 12:15   ` Hannu Hartikainen
2021-06-26 17:36 ` David Bremner
2021-06-28  7:11   ` Hannu Hartikainen
2021-07-02  9:13   ` [PATCH v2 1/2] reply: add test for multiple Delivered-To headers Hannu Hartikainen
2021-07-02  9:13     ` [PATCH v2 2/2] lib: consider all instances of Delivered-To header Hannu Hartikainen
2021-08-30  1:13     ` [PATCH v2 1/2] reply: add test for multiple Delivered-To headers David Bremner

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).