sending email using different server for different 'From:' field

David Belohrad david at belohrad.ch
Wed Sep 3 00:16:51 PDT 2014


oukej. this seems to be exactly what I'm looking for. Is there a way how
to 'cycle' in notmuch different From: fields? I'd need to setup like 3
addresses, each of them with different signatures and be able to easily
switch between them....

thanks
.d.


Keith Amidon <camalot at picnicpark.org> writes:

> 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