--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\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 D56076DE1B22\r
+ for <notmuch@notmuchmail.org>; Sat, 2 Jan 2016 03:27:49 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.676\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.676 tagged_above=-999 required=5 tests=[AWL=0.024, \r
+ SPF_NEUTRAL=0.652] 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 dkroVeIZtIqU for <notmuch@notmuchmail.org>;\r
+ Sat, 2 Jan 2016 03:27:46 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by arlo.cworth.org (Postfix) with ESMTP id A58C66DE1B1D\r
+ for <notmuch@notmuchmail.org>; Sat, 2 Jan 2016 03:27:44 -0800 (PST)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id D286310008D;\r
+ Sat, 2 Jan 2016 13:28:02 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: J Farkas <jf.hyqohaczlksw4tx6ae@l2015aftruuq.dns007.net>,\r
+ notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] cli/insert: do not lose the SMTP envelope\r
+In-Reply-To: <1451647279.42.86b0a8ab@201601.l2015aftruuq.dns007.net>\r
+References: <1451647279.42.86b0a8ab@201601.l2015aftruuq.dns007.net>\r
+User-Agent: Notmuch/0.21+32~g73439f8 (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Sat, 02 Jan 2016 13:28:02 +0200\r
+Message-ID: <m2a8oob4ql.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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: Sat, 02 Jan 2016 11:27:50 -0000\r
+\r
+On Fri, Jan 01 2016, J Farkas <jf.hyqohaczlksw4tx6ae@l2015aftruuq.dns007.net> wrote:\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
+Probably good feature, but like\r
+http://www.qmail.org/man/man8/qmail-command.html \r
+says:\r
+\r
+ qmail-local supplies several useful environment variables to\r
+ command. WARNING: These environment variables are not\r
+ quoted. They may contain special characters. They are\r
+ under the control of a possibly malicious remote user.\r
+\r
+Should we check that the contents of RPLINE and DTLINE are well-formed\r
+before writing these to the mail files ?\r
+\r
+Tomi\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
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> https://notmuchmail.org/mailman/listinfo/notmuch\r