unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Hooks for sending/replying to set a custom header
@ 2024-10-03  7:00 Xiyue Deng
  2024-10-03 15:44 ` David Bremner
  0 siblings, 1 reply; 5+ messages in thread
From: Xiyue Deng @ 2024-10-03  7:00 UTC (permalink / raw)
  To: notmuch


[-- Attachment #1.1: Type: text/plain, Size: 1143 bytes --]

Hi,

Let me start by saying that I have been enjoying notmuch recently and
wish I had tried notmuch much earlier.

I do encounter a small issue on managing multiple email accounts: I set
`message-default-mail-headers' with the SMTP settings and email address
so that smtpmail can send the mail through my specified email address,
and would like to change this setting based on which address I'm sending
from.  However I'm having trouble finding the best place to set this in
notmuch when sending/replying.  AIUI notmuch does not really have the
concept of mail account, so this may require some manual handling.  I
tried to `re-search-forward' in notmuch-message-mode-hook for the `From:
' header, but at that stage the buffer seems to be empty.  I found one
Emacs tip that can set the sender to a fix address for all mails, but
not any customizations based on the sender.  Basically, I'm looking for
something like `gnus-posting-style' in Gnus or context change hook in
mu4e.  Is there a way to achieve this (or maybe I am missing something)?

Thanks in advance, and thanks for the great work on notmuch!
-- 
Xiyue Deng

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 857 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Hooks for sending/replying to set a custom header
  2024-10-03  7:00 Hooks for sending/replying to set a custom header Xiyue Deng
@ 2024-10-03 15:44 ` David Bremner
  2024-10-03 17:22   ` Xiyue Deng
  0 siblings, 1 reply; 5+ messages in thread
From: David Bremner @ 2024-10-03 15:44 UTC (permalink / raw)
  To: Xiyue Deng, notmuch

Xiyue Deng <manphiz@gmail.com> writes:

> Let me start by saying that I have been enjoying notmuch recently and
> wish I had tried notmuch much earlier.
>
> I do encounter a small issue on managing multiple email accounts: I set
> `message-default-mail-headers' with the SMTP settings and email address
> so that smtpmail can send the mail through my specified email address,
> and would like to change this setting based on which address I'm sending
> from.  However I'm having trouble finding the best place to set this in
> notmuch when sending/replying.  AIUI notmuch does not really have the
> concept of mail account, so this may require some manual handling.  I
> tried to `re-search-forward' in notmuch-message-mode-hook for the `From:


You could try out message-templ (elpa-message-templ in Debian). I'm
using that to set the X-Message-SMTP-Method header, which sounds
related.

There is also message-server-alist, which does not need a header.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Hooks for sending/replying to set a custom header
  2024-10-03 15:44 ` David Bremner
@ 2024-10-03 17:22   ` Xiyue Deng
  2024-10-05 14:13     ` David Bremner
  0 siblings, 1 reply; 5+ messages in thread
From: Xiyue Deng @ 2024-10-03 17:22 UTC (permalink / raw)
  To: David Bremner, notmuch


[-- Attachment #1.1: Type: text/plain, Size: 1437 bytes --]

Hi David,

David Bremner <david@tethera.net> writes:

> Xiyue Deng <manphiz@gmail.com> writes:
>
>> Let me start by saying that I have been enjoying notmuch recently and
>> wish I had tried notmuch much earlier.
>>
>> I do encounter a small issue on managing multiple email accounts: I set
>> `message-default-mail-headers' with the SMTP settings and email address
>> so that smtpmail can send the mail through my specified email address,
>> and would like to change this setting based on which address I'm sending
>> from.  However I'm having trouble finding the best place to set this in
>> notmuch when sending/replying.  AIUI notmuch does not really have the
>> concept of mail account, so this may require some manual handling.  I
>> tried to `re-search-forward' in notmuch-message-mode-hook for the `From:
>
>
> You could try out message-templ (elpa-message-templ in Debian). I'm
> using that to set the X-Message-SMTP-Method header, which sounds
> related.
>
> There is also message-server-alist, which does not need a header.

Thanks for the tip!  I think that should work, though I'd like a more
notmuch-ish solution if possible.  And in fact I had some success on
advising `notmuch-mua-mail' and reacting on 'From from `other-headers'.

I wonder whether notmuch may consider adding an abnormal hook that pass
in `headers' as an argument so that we don't need to use an advice?

-- 
Xiyue Deng

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 857 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Hooks for sending/replying to set a custom header
  2024-10-03 17:22   ` Xiyue Deng
@ 2024-10-05 14:13     ` David Bremner
  2024-10-07  5:37       ` Xiyue Deng
  0 siblings, 1 reply; 5+ messages in thread
From: David Bremner @ 2024-10-05 14:13 UTC (permalink / raw)
  To: Xiyue Deng, notmuch

Xiyue Deng <manphiz@gmail.com> writes:

>>
>> There is also message-server-alist, which does not need a header.
>
> Thanks for the tip!  I think that should work, though I'd like a more
> notmuch-ish solution if possible.  And in fact I had some success on
> advising `notmuch-mua-mail' and reacting on 'From from `other-headers'.
>
> I wonder whether notmuch may consider adding an abnormal hook that pass
> in `headers' as an argument so that we don't need to use an advice?

I'd consider message-server-alist to be the "notmuch-ish" solution,
since we generally expect message-mode configuration to work for
notmuch-message-mode.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Hooks for sending/replying to set a custom header
  2024-10-05 14:13     ` David Bremner
@ 2024-10-07  5:37       ` Xiyue Deng
  0 siblings, 0 replies; 5+ messages in thread
From: Xiyue Deng @ 2024-10-07  5:37 UTC (permalink / raw)
  To: David Bremner, notmuch

David Bremner <david@tethera.net> writes:

> Xiyue Deng <manphiz@gmail.com> writes:
>
>>>
>>> There is also message-server-alist, which does not need a header.
>>
>> Thanks for the tip!  I think that should work, though I'd like a more
>> notmuch-ish solution if possible.  And in fact I had some success on
>> advising `notmuch-mua-mail' and reacting on 'From from `other-headers'.
>>
>> I wonder whether notmuch may consider adding an abnormal hook that pass
>> in `headers' as an argument so that we don't need to use an advice?
>
> I'd consider message-server-alist to be the "notmuch-ish" solution,
> since we generally expect message-mode configuration to work for
> notmuch-message-mode.

Thanks for the suggestion!  I wasn't aware of this variable and I think
this does exactly what I intend to do.

One slight inconvenience is that the settings are used to set the header
during `message-send', which means you may not see the header being set
when you are editing the mail.  So if there is an error in your setting
you may not notice it until it is sent, which could be a bit late.  I
wish there is something that can be used to do this in
`message-mode-hook', but I guess I can settle for this for now.

Again, thanks for the tip and the work on notmuch!

-- 
Xiyue Deng

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-10-07  5:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-03  7:00 Hooks for sending/replying to set a custom header Xiyue Deng
2024-10-03 15:44 ` David Bremner
2024-10-03 17:22   ` Xiyue Deng
2024-10-05 14:13     ` David Bremner
2024-10-07  5:37       ` Xiyue Deng

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).