sending email using different server for different 'From:' field
Keith Amidon
camalot at picnicpark.org
Tue Sep 2 07:35:11 PDT 2014
On Tue, 2014-09-02 at 14:26 +0200, David Belohrad wrote:
> could that scenario be somehow fitted automatically, so when I overwrite
> the default 'From:' address (by hand. is it possible to do some
> automatic cycling?) to work address, so that message sender in emacs
> would automatically use work exchange server to deliver the mail?
I think this is more of a message-mode question than a notmuch question.
I use something very similar to code attached below, which is rather
brute-force, but does the job for me.
--- Keith
-----
(defun kea/send-mail-with-x ()
(interactive)
(setq smtpmail-smtp-server "smtp.x.com"
smtpmail-smtp-service 587
smtpmail-local-domain "x.com"
smtpmail-auth-user nil
smtpmail-stream-type 'starttls))
(defun kea/send-mail-with-y ()
(interactive)
(setq smtpmail-smtp-server "email.y.com"
smtpmail-smtp-service 587
smtpmail-local-domain "y.com"
smtpmail-auth-user nil
smtpmail-stream-type 'starttls))
(defun kea/message-select-mail-dest ()
(cond ((string-match "<kea at x.com>"
(message-field-value "From"))
(kea/send-mail-with-x))
(t
(kea/send-mail-with-y))))
(kea/send-mail-with-y)
(add-hook 'message-send-hook 'kea/message-select-mail-dest)
More information about the notmuch
mailing list