Set "From" based on "To" when replying

Simon Campese notmuchmail_org at campese.de
Fri Feb 10 15:51:00 PST 2012


> Yeah, I think this is the point: you want "*@mydomain.org" to be one of
> the user.other_email.  I don't see why that couldn't be done with a
> little work in notmuch-reply.c.  I wouldn't mind seeing this
> functionality as well, actually.

So here's my shabby solution (pasted from my .emacs):

;;automatically take From: from To: if mail was sent to .*@mydomain.org

(defun notmuch-show-reply-sender-mod ()
  (interactive)
(if (string-match ".*@campese.de" (notmuch-show-get-header :To))
(notmuch-mua-reply (notmuch-show-get-message-id) (notmuch-show-get-header :To)
nil) (notmuch-show-reply-sender)))

(defun notmuch-show-reply-mod ()
  (interactive)
(if (string-match ".*@campese.de" (notmuch-show-get-header :To))
(notmuch-mua-reply (notmuch-show-get-message-id) (notmuch-show-get-header :To) t)
(notmuch-show-reply)))

(define-key notmuch-show-mode-map "r" 'notmuch-show-reply-sender-mod)
(define-key notmuch-show-mode-map "R" 'notmuch-show-reply-mod)

If it sees "@mydomain.org" in the 'To'-header, it copies the whole
"To:"-header to the "From:" header when replying. This works as long as
I'm the only one in the "To:"-header, which usually is the case (I only
use this "special" email addreses when registering at online-shops,
forums, etc. to be able to easily track where spammers got my email
from.

I totally agree that a clean solution would be regular expressions in
the primary_email and other_email fields in notmuch-config.

Anyone up for implementing this? :-)

Best,

Simon


More information about the notmuch mailing list