--- /dev/null
+Return-Path: <jf.hyqohaczlksw4tx6ae@l2015aftruuq.dns007.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 48FAC6DE1A5C\r
+ for <notmuch@notmuchmail.org>; Fri, 1 Jan 2016 03:29:42 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.198\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.198 tagged_above=-999 required=5 tests=[AWL=0.001, \r
+ DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001,\r
+ TVD_FROM_1=0.999] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id jXS4_ur-9qna for <notmuch@notmuchmail.org>;\r
+ Fri, 1 Jan 2016 03:29:40 -0800 (PST)\r
+X-Greylist: delayed 496 seconds by postgrey-1.35 at arlo;\r
+ Fri, 01 Jan 2016 03:29:39 PST\r
+Received: from know-smtprelay-omc-6.server.virginmedia.net\r
+ (know-smtprelay-omc-6.server.virginmedia.net [80.0.253.70])\r
+ by arlo.cworth.org (Postfix) with ESMTP id C8CBE6DE1642\r
+ for <notmuch@notmuchmail.org>; Fri, 1 Jan 2016 03:29:39 -0800 (PST)\r
+Received: from dev.koan19.net ([82.1.197.255])\r
+ by know-smtprelay-6-imp with bizsmtp\r
+ id 0bMM1s00M5X6CWA01bMMZN; Fri, 01 Jan 2016 11:21:21 +0000\r
+X-Originating-IP: [82.1.197.255]\r
+X-Spam: 0\r
+X-Authority: v=2.1 cv=P+nH/X0u c=1 sm=1 tr=0 a=D+CNGfzuhY6ArhcYgadsyQ==:117\r
+ a=D+CNGfzuhY6ArhcYgadsyQ==:17 a=jxr8AxaCAAAA:8 a=dmPqMsitAAAA:8\r
+ a=hov-Noh0Y1sA:10 a=kj9zAlcOel0A:10 a=pGLkceISAAAA:8 a=QS_f28TmvQGgleWyFkgA:9\r
+ a=CjuIK1q_8ugA:10\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;\r
+ d=l2015aftruuq.dns007.net; i=@l2015aftruuq.dns007.net; q=dns/txt; s=l201512;\r
+ t=1451647280; h=To : Subject : MIME-Version : Content-Type : From :\r
+ Message-ID : Date : X-Originating-IP : Subject : From : Date;\r
+ bh=VzbZWKzDWGaqv+8aF2Q7X1XMCAoFt+JCkczPKyqmkPk=;\r
+ b=AQM3nYOdP80NIXUNHQubmJ0p/e/m+gC9TV0P2FzGBHzBgEnagMQoSvFcmOgSPTaVvkmTVA\r
+ IEbSn5kP/bZtPVX6LhrbG2ZfeckweHbBrZ4vXjgQweJYne4mHwQx9EoAWjenocY6Q0dxhc0c\r
+ ym9GcwnvqgE3lK/yUMlm7XK+ocoDpTU2e1QKLfIY4NkJt6nloVvVejmgSHenbvuTpKwrQp8g ==\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] cli/insert: do not lose the SMTP envelope\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+User-Agent: Mutt/1.5.23.1 (2014-03-12)\r
+From: J Farkas <jf.hyqohaczlksw4tx6ae@l2015aftruuq.dns007.net>\r
+Message-ID: <1451647279.42.86b0a8ab@201601.l2015aftruuq.dns007.net>\r
+Date: Fri, 01 Jan 2016 11:21:19 +0000\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 01 Jan 2016 11:29:42 -0000\r
+\r
+From: Janos Farkas <chexum+dev@gmail.com>\r
+Subject: [PATCH] cli/insert: do not lose the SMTP envelope\r
+\r
+Make sure we store the envelope sender/recipient if provided by\r
+qmail-command(8) in $RPLINE and $DTLINE.\r
+---\r
+\r
+I just realised that the messages delivered directly into maildir don't have\r
+the usual envelope addresses that qmail provides. This is a piece of\r
+information that's important to (at least my) troubleshooting, so I created a\r
+patch that seems to work well, applies cleanly to master (and 0.21), and\r
+provided a NEWS entry should it be necessary.\r
+\r
+ NEWS | 9 +++++++++\r
+ notmuch-insert.c | 28 ++++++++++++++++++++++++++++\r
+ 2 files changed, 37 insertions(+)\r
+\r
+diff --git a/NEWS b/NEWS\r
+index 6681699..13d45c8 100644\r
+--- a/NEWS\r
++++ b/NEWS\r
+@@ -1,3 +1,12 @@\r
++\r
++\r
++`notmuch insert` records the envelope addresses if available\r
++\r
++ If the caller provides this information as qmail-command(8) does in\r
++ the RPLINE and DTLINE environment variables, then notmuch insert will\r
++ record it in the maildir file.\r
++\r
++\r
+ Notmuch 0.21 (2015-10-29)\r
+ =========================\r
+ \r
+diff --git a/notmuch-insert.c b/notmuch-insert.c\r
+index 5205c17..ecc0fa0 100644\r
+--- a/notmuch-insert.c\r
++++ b/notmuch-insert.c\r
+@@ -284,6 +284,26 @@ copy_fd (int fdout, int fdin)\r
+ }\r
+ \r
+ /*\r
++ * Write zero (and LF) terminated string to the output fd. It's expected to\r
++ * come from getenv(), so it's not checked for correctness. NULL or empty\r
++ * string is ignored, successfully.\r
++ * Return TRUE on success, FALSE on errors.\r
++ */\r
++static notmuch_bool_t\r
++write_header (int fdout, const char *hdr)\r
++{\r
++ ssize_t written,to_write;\r
++\r
++ if (hdr && (to_write = strlen (hdr))) {\r
++ written = write (fdout, hdr, to_write);\r
++ if (written != to_write)\r
++ return FALSE;\r
++ }\r
++\r
++ return TRUE;\r
++}\r
++\r
++/*\r
+ * Write fdin to a new temp file in maildir/tmp, return full path to\r
+ * the file, or NULL on errors.\r
+ */\r
+@@ -297,6 +317,14 @@ maildir_write_tmp (const void *ctx, int fdin, const char *maildir)\r
+ if (fdout < 0)\r
+ return NULL;\r
+ \r
++ /* maildir(5) suggests the message should start with a Return-Path\r
++ * and Delivered-To lines. qmail-local(8) supplies these.\r
++ */\r
++ if (! write_header(fdout, getenv("RPLINE")))\r
++ goto FAIL;\r
++ if (! write_header(fdout, getenv("DTLINE")))\r
++ goto FAIL;\r
++\r
+ if (! copy_fd (fdout, fdin))\r
+ goto FAIL;\r
+ \r
+-- \r
+2.6.3\r
+\r