Multiple sender identities (composing)

Subject: Multiple sender identities (composing)

Date: Mon, 16 May 2011 19:29:07 +1000

To: notmuch

Cc:

From: Stewart Smith


Thought I'd share this bit of my .emacs snippet that may be useful to go
on the emacs tips page.

This does the following:
- sets up a list of possible identities to have mail From
- on composing mail, it prompts you for who you want to send mail from
- pressing enter will give you the default (first in the list)
- otherwise you have tab completion

You may also want to set this:
 '(message-sendmail-envelope-from (quote header))
(in custom-set-variables) so that if you're doing postfix sender based routing
or the like, it gets the correct address and doesn't end up sending
things the wrong way.

(setq stewart/mua-identities (list "Stewart Smith <stewart@flamingspork.com>" "Stewart Smith <stewart.smith@percona.com>"))

(defun stewart/notmuch-mua-mail (&optional from)
  (interactive)
  (setq from (completing-read "Sender identity: " stewart/mua-identities
		   nil t nil nil (car stewart/mua-identities)))
  (notmuch-mua-mail nil nil (list (cons 'from from))))

(define-key notmuch-show-mode-map "m"
      (lambda ()
        "send email"
        (interactive)
	(stewart/notmuch-mua-mail)))

(define-key notmuch-search-mode-map "m"
      (lambda ()
        "send email"
        (interactive)
	(stewart/notmuch-mua-mail)))

-- 
Stewart Smith

Thread: