From: David Mazieres Date: Wed, 22 Jul 2015 00:21:36 +0000 (+1700) Subject: Re: Modify message after send...? X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=52374a53838f12de21a6b68a4002582bf004525d;p=notmuch-archives.git Re: Modify message after send...? --- diff --git a/37/755c464b8ee0ec573a0fc1949799b35e7ffbd3 b/37/755c464b8ee0ec573a0fc1949799b35e7ffbd3 new file mode 100644 index 000000000..a39947661 --- /dev/null +++ b/37/755c464b8ee0ec573a0fc1949799b35e7ffbd3 @@ -0,0 +1,100 @@ +Return-Path: + +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id C711C6DE0B27 + for ; Tue, 21 Jul 2015 17:41:45 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -2.055 +X-Spam-Level: +X-Spam-Status: No, score=-2.055 tagged_above=-999 required=5 tests=[AWL=0.796, + RCVD_IN_DNSWL_MED=-2.3, RP_MATCHES_RCVD=-0.55, SPF_PASS=-0.001] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id daGRXxEK5NSx for ; + Tue, 21 Jul 2015 17:41:43 -0700 (PDT) +X-Greylist: delayed 1203 seconds by postgrey-1.35 at arlo; + Tue, 21 Jul 2015 17:41:43 PDT +Received: from market.scs.stanford.edu (market.scs.stanford.edu [171.66.3.10]) + by arlo.cworth.org (Postfix) with ESMTPS id B32AC6DE0AD1 + for ; Tue, 21 Jul 2015 17:41:43 -0700 (PDT) +Received: from market.scs.stanford.edu (localhost.scs.stanford.edu + [127.0.0.1]) by market.scs.stanford.edu (8.14.7/8.14.7) with ESMTP id + t6M0LbSw027122; Tue, 21 Jul 2015 17:21:37 -0700 (PDT) +Received: (from dm@localhost) + by market.scs.stanford.edu (8.14.7/8.14.7/Submit) id t6M0LbPk016153; + Tue, 21 Jul 2015 17:21:37 -0700 (PDT) +X-Authentication-Warning: market.scs.stanford.edu: dm set sender to + return-dqk5s59tpxtrvs7yjhukdm9c56@ta.scs.stanford.edu using -f +From: David Mazieres +To: mailinglists@nawaz.org, notmuch@notmuchmail.org +Subject: Re: Modify message after send...? +In-Reply-To: <878uacpwse.fsf@fester.com> +References: <878uacpwse.fsf@fester.com> +Reply-To: David Mazieres expires 2015-10-19 PDT + +Date: Tue, 21 Jul 2015 17:21:36 -0700 +Message-ID: <87y4i9xcrz.fsf@ta.scs.stanford.edu> +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +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: Wed, 22 Jul 2015 00:41:45 -0000 + +mailinglists@nawaz.org writes: + +> Hi, +> +> I use notmuch via Emacs. +> +> Here's what I want: +> +> When I hit C-c C-c to send a message, I'd like it to be passed to a +> script (likely a Python one, although I may consider an Elisp function +> if an external script is not possible) for modification of headers, +> before it is sent to the MTA (Postfix in my case). A bonus would be to +> have the modified message stored in the FCC location, instead of the +> original one. +> +> Is this possible? An alternative may be to modify the message /before/ +> it goes to message-send-and-exit. I'm inexperienced in Elisp - would +> this be via what's called "advising"? +> +> BTW, all I really want to do is modify the From: field based on the +> recipients (for every email, with no default From). I'll welcome +> suggestions for existing ways to do that. I Googled a little, but didn't +> find a clear good solution. Furthermore, I expect over time the rules by +> which I pick the From: field will get more complex than my knowledge of +> Elisp. + +For modifying the From field, I recommend doing it before you send the +message, as this gives you an opportunity to see what you are about to +send and possibly edit it by hand. + +I do something like this using defadvice around notmuch-mua-mail, do +adjust things about my messages. I also put a defadvice around +notmuch-call-notmuch-sexp to filter the To and Cc headers I get from +"notmuch reply" (because notmuch won't let me put wildcards in my +.notmuch-config file). + +Finally, and possibly most relevant to you, I use a message-send-hook to +insert the Return-Path address and make a few more modifications before +sending a message. Note that I only do this if there isn't already a +Return-Path header. That way, if I type C-c C-c and don't like what I +see, I edit the result and send again, leaving the generated Return-Path +header, and this time it goes through unmodified. + +David