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