Modify message after send...?

MN mailinglists at nawaz.org
Sun Jul 19 09:57:46 PDT 2015


On 2015-07-19 00:59, David Bremner wrote:
> mailinglists at nawaz.org writes:
>
>> 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.
>
> I'm afraid it's a bit "some-assembly-required", but let me mention 
> one
> possible solution.
>
> At least if you just want to have a regular expression match on the
> recipient, then the example configuration in message-templ [1] may be
> enough to get you started. You'd have to either call
> message-templ-config-exec in a hook, or bind it to a key and call it
> manually to set up the headers before sending.
>
> [1]: http://pivot.cs.unb.ca/git?p=message-templ.git;a=tree

Thanks for this. I'll see if I can follow the Elisp code.

After sending my email, it occurred to me that message handling is not 
notmuch's job - that's passed on to message-mode. I figured message-mode 
must have some kind of hook before sending the email, and sure enough, 
it does have message-send-hook. The example at 
www.gnu.org/software/emacs/manual/html_mono/message.html shows how one 
can add headers before sending. There's also message-alternative-emails, 
although that likely works only if you're replying to an email.

A little frustrating: They have a number of functions to modify/read 
fields like Subject, or To - but none for From! So I'll still have to do 
some surgery. I'll likely use the send-message-hook to:

1. Read the "To" & "cc" values.
2. Pass them to an external Python script.
3. Get the appropriate "From" field from the Python script.
4. Insert it into the From: field.

How does one do steps 2 & 3 in Elisp? I just need a pointer. (Just 
Googled and saw this: 
http://stackoverflow.com/questions/5014246/how-to-capture-standard-output-of-a-shell-command-in-elisp)

Thanks,


More information about the notmuch mailing list