unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* sending email using different server for different 'From:' field
@ 2014-09-02 12:26 David Belohrad
  2014-09-02 14:35 ` Keith Amidon
  0 siblings, 1 reply; 5+ messages in thread
From: David Belohrad @ 2014-09-02 12:26 UTC (permalink / raw)
  To: notmuch

Dear All,

I have my emacs/notmuch installation setup such, that I send the emails
usually directly using local exim4 installation. For particular 'From:'
field however I need to use my work server. Nowadays I do that
manually. Hence if I write an email using my work address, I manually
call a function switching the exim4 to work server. when the mail is
sent, i manually set it back to exim.

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?


many thanks


david

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

* Re: sending email using different server for different 'From:' field
  2014-09-02 12:26 sending email using different server for different 'From:' field David Belohrad
@ 2014-09-02 14:35 ` Keith Amidon
  2014-09-03  7:16   ` David Belohrad
  0 siblings, 1 reply; 5+ messages in thread
From: Keith Amidon @ 2014-09-02 14:35 UTC (permalink / raw)
  To: David Belohrad; +Cc: notmuch

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@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)

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

* Re: sending email using different server for different 'From:' field
  2014-09-02 14:35 ` Keith Amidon
@ 2014-09-03  7:16   ` David Belohrad
  2014-09-03  8:31     ` Mark Walters
  0 siblings, 1 reply; 5+ messages in thread
From: David Belohrad @ 2014-09-03  7:16 UTC (permalink / raw)
  To: Keith Amidon, notmuch

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@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@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)

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

* Re: sending email using different server for different 'From:' field
  2014-09-03  7:16   ` David Belohrad
@ 2014-09-03  8:31     ` Mark Walters
  2014-09-05 21:47       ` David Belohrad
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Walters @ 2014-09-03  8:31 UTC (permalink / raw)
  To: David Belohrad, Keith Amidon, notmuch


Hi

On Wed, 03 Sep 2014, David Belohrad <david@belohrad.ch> wrote:
> 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....

You might finding setting notmuch-always-prompt-for-sender to 't is
what you want (you can set if in customise or directly)

This prompts you for the sender address and takes options from your
notmuch config file (that is from user.primary_email and
user.other_email from .notmuch-config) so will quite possibly just work.


>>
>> (defun kea/message-select-mail-dest ()
>>   (cond ((string-match "<kea@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)

I will also mention an alternative approach to using hooks here. You
could customise message-send-mail-function to be your own function which
let binds the appropriate send-mail settings and have that call the
actual send-mail function (eg message-send-mail-with-sendmail)

Best wishes

Mark

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

* Re: sending email using different server for different 'From:' field
  2014-09-03  8:31     ` Mark Walters
@ 2014-09-05 21:47       ` David Belohrad
  0 siblings, 0 replies; 5+ messages in thread
From: David Belohrad @ 2014-09-05 21:47 UTC (permalink / raw)
  To: Mark Walters, Keith Amidon, notmuch

Dear Both,
thanks  alot, i'll try to see those options (when i find a bit of
time :)

nice evening (in europe at least)

.d.


Mark Walters <markwalters1009@gmail.com> writes:

> Hi
>
> On Wed, 03 Sep 2014, David Belohrad <david@belohrad.ch> wrote:
>> 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....
>
> You might finding setting notmuch-always-prompt-for-sender to 't is
> what you want (you can set if in customise or directly)
>
> This prompts you for the sender address and takes options from your
> notmuch config file (that is from user.primary_email and
> user.other_email from .notmuch-config) so will quite possibly just work.
>
>
>>>
>>> (defun kea/message-select-mail-dest ()
>>>   (cond ((string-match "<kea@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)
>
> I will also mention an alternative approach to using hooks here. You
> could customise message-send-mail-function to be your own function which
> let binds the appropriate send-mail settings and have that call the
> actual send-mail function (eg message-send-mail-with-sendmail)
>
> Best wishes
>
> Mark

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

end of thread, other threads:[~2014-09-05 21:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-02 12:26 sending email using different server for different 'From:' field David Belohrad
2014-09-02 14:35 ` Keith Amidon
2014-09-03  7:16   ` David Belohrad
2014-09-03  8:31     ` Mark Walters
2014-09-05 21:47       ` David Belohrad

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).