Gnus development mailing list
 help / color / mirror / Atom feed
* separate smtps for my accounts
@ 2014-09-12  0:58 Sharon Kimble
  2014-09-12  2:08 ` Eric Abrahamsen
  0 siblings, 1 reply; 10+ messages in thread
From: Sharon Kimble @ 2014-09-12  0:58 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 419 bytes --]


In my gnus setup I have 1 pop3 account, and 3 imap accounts, but only
one smtp address. How can I have a separate smtp settings so that I am
able to reply via the address of the email that I've just received?

Thanks
Sharon.
-- 
A taste of linux = http://www.sharons.org.uk
my git repo = https://bitbucket.org/boudiccas/dots
TGmeds = http://www.tgmeds.org.uk
Debian testing, fluxbox 1.3.5, emacs 24.3.93.1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

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

* Re: separate smtps for my accounts
  2014-09-12  0:58 separate smtps for my accounts Sharon Kimble
@ 2014-09-12  2:08 ` Eric Abrahamsen
  2014-09-12 15:05   ` Jorge A. Alfaro-Murillo
  2014-09-13 22:03   ` Sharon Kimble
  0 siblings, 2 replies; 10+ messages in thread
From: Eric Abrahamsen @ 2014-09-12  2:08 UTC (permalink / raw)
  To: ding

Sharon Kimble <boudiccas@skimble.plus.com> writes:

> In my gnus setup I have 1 pop3 account, and 3 imap accounts, but only
> one smtp address. How can I have a separate smtp settings so that I am
> able to reply via the address of the email that I've just received?
>
> Thanks
> Sharon.

The details depend a little bit on the exact program you're using for
sending mail, but generally the rigmarole looks like this (I use msmtp):

(defun cg-feed-msmtp ()
  (if (message-mail-p)
      (save-excursion
	(let* ((from
		(save-restriction
		  (message-narrow-to-headers)
		  (message-fetch-field "from")))
	       (account
		(cond
		 ;; I use email address as account label in ~/.msmtprc
		 ((string-match "eric@ericabrahamsen.net" from) "ea")
		 ((string-match "account_two@gmail.com" from) "acc2")
		 ((string-match "more_accounts@domain.org" from) "more"))))
	  (setq message-sendmail-extra-arguments (list '"-a" account))))))

(setq message-sendmail-envelope-from 'header)
(add-hook 'message-send-mail-hook 'cg-feed-msmtp)




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

* Re: separate smtps for my accounts
  2014-09-12  2:08 ` Eric Abrahamsen
@ 2014-09-12 15:05   ` Jorge A. Alfaro-Murillo
  2014-09-13 22:03   ` Sharon Kimble
  1 sibling, 0 replies; 10+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2014-09-12 15:05 UTC (permalink / raw)
  To: ding

Eric Abrahamsen writes: 

> Sharon Kimble <boudiccas@skimble.plus.com> writes: 
> 
>> In my gnus setup I have 1 pop3 account, and 3 imap accounts, 
>> but only one smtp address. How can I have a separate smtp 
>> settings so that I am able to reply via the address of the 
>> email that I've just received? 
>> 
>> Thanks Sharon. 
> 
> The details depend a little bit on the exact program you're 
> using for sending mail, but generally the rigmarole looks like 
> this (I use msmtp): 
> 
> (defun cg-feed-msmtp () 
>   (if (message-mail-p) 
>       (save-excursion 
> 	(let* ((from (save-restriction (message-narrow-to-headers) 
> (message-fetch-field "from"))) (account (cond ;; I use email 
> address as account label in ~/.msmtprc ((string-match 
> "eric@ericabrahamsen.net" from) "ea") ((string-match 
> "account_two@gmail.com" from) "acc2") ((string-match 
> "more_accounts@domain.org" from) "more")))) (setq 
> message-sendmail-extra-arguments (list '"-a" account)))))) 
> 
> (setq message-sendmail-envelope-from 'header) (add-hook 
> 'message-send-mail-hook 'cg-feed-msmtp) 
>   

I have two smtp addresses, one for work and a personal one at 
Gmail, and I used to have a similar setup. But I discovered 
recently that you can configure Gmail to send mail from another 
address (In Gmail: Settings, Accounts and Import, Send mail as), 
so I just left my smtpmail with gmail, and now Gmail decides from 
where to send the email according to the "From" field in the 
message.

I set up my user-mail-address as my work email, since that is the 
one I generally use, and then use gnus-posting-styles, so that if 
someone sends me a personal email, I reply using the personal 
email:

#+BEGIN_SRC emacs-lisp
  (setq gnus-posting-styles 
        `(
  ...     
          ((header "To" ,(regexp-quote "username@gmail.com")) 
           (address "username@gmail.com")) 
          ((header "CC" ,(regexp-quote "username@gmail.com")) 
           (address "username@gmail.com")) 
          ((header "BCC" ,(regexp-quote "username@gmail.com")) 
           (address "username@gmail.com"))
  ...
 
#+END_SRC

This method has the advantage of keeping a copy of the sent mail 
from the work address in the Sent Mail folder of Gmail, so all 
sent mail is in one place.


Best,

-- 
Jorge.




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

* Re: separate smtps for my accounts
  2014-09-12  2:08 ` Eric Abrahamsen
  2014-09-12 15:05   ` Jorge A. Alfaro-Murillo
@ 2014-09-13 22:03   ` Sharon Kimble
  2014-09-14  2:01     ` Eric Abrahamsen
  2014-09-17  8:37     ` Eric S Fraga
  1 sibling, 2 replies; 10+ messages in thread
From: Sharon Kimble @ 2014-09-13 22:03 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 1507 bytes --]

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Sharon Kimble <boudiccas@skimble.plus.com> writes:
>
>> In my gnus setup I have 1 pop3 account, and 3 imap accounts, but only
>> one smtp address. How can I have a separate smtp settings so that I am
>> able to reply via the address of the email that I've just received?
>>
>> Thanks
>> Sharon.
>
> The details depend a little bit on the exact program you're using for
> sending mail, but generally the rigmarole looks like this (I use
> msmtp):

I'm using whatever the default is with Debian testing, sorry! Exim4? I
don't know what it is, but reportbug is able to send through it.

Sharon.

>
> (defun cg-feed-msmtp ()
>   (if (message-mail-p)
>       (save-excursion
> 	(let* ((from
> 		(save-restriction
> 		  (message-narrow-to-headers)
> 		  (message-fetch-field "from")))
> 	       (account
> 		(cond
> 		 ;; I use email address as account label in ~/.msmtprc
> 		 ((string-match "eric@ericabrahamsen.net" from) "ea")
> 		 ((string-match "account_two@gmail.com" from) "acc2")
> 		 ((string-match "more_accounts@domain.org" from) "more"))))
> 	  (setq message-sendmail-extra-arguments (list '"-a" account))))))
>
> (setq message-sendmail-envelope-from 'header)
> (add-hook 'message-send-mail-hook 'cg-feed-msmtp)
>
>
>

-- 
A taste of linux = http://www.sharons.org.uk
my git repo = https://bitbucket.org/boudiccas/dots
TGmeds = http://www.tgmeds.org.uk
Debian testing, fluxbox 1.3.5, emacs 24.3.93.1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

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

* Re: separate smtps for my accounts
  2014-09-13 22:03   ` Sharon Kimble
@ 2014-09-14  2:01     ` Eric Abrahamsen
  2014-09-16 18:57       ` Sharon Kimble
  2014-09-17  8:37     ` Eric S Fraga
  1 sibling, 1 reply; 10+ messages in thread
From: Eric Abrahamsen @ 2014-09-14  2:01 UTC (permalink / raw)
  To: ding

Sharon Kimble <boudiccas@skimble.plus.com> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> Sharon Kimble <boudiccas@skimble.plus.com> writes:
>>
>>> In my gnus setup I have 1 pop3 account, and 3 imap accounts, but only
>>> one smtp address. How can I have a separate smtp settings so that I am
>>> able to reply via the address of the email that I've just received?
>>>
>>> Thanks
>>> Sharon.
>>
>> The details depend a little bit on the exact program you're using for
>> sending mail, but generally the rigmarole looks like this (I use
>> msmtp):
>
> I'm using whatever the default is with Debian testing, sorry! Exim4? I
> don't know what it is, but reportbug is able to send through it.
>
> Sharon.

Here's what I've got for mail sending setup, what is your value of
message-send-mail-function?

(setq message-send-mail-function 'message-send-mail-with-sendmail)
(setq sendmail-program "msmtp")




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

* Re: separate smtps for my accounts
  2014-09-14  2:01     ` Eric Abrahamsen
@ 2014-09-16 18:57       ` Sharon Kimble
  2014-09-17  2:17         ` Eric Abrahamsen
  2014-09-17 12:32         ` Rasmus
  0 siblings, 2 replies; 10+ messages in thread
From: Sharon Kimble @ 2014-09-16 18:57 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 1616 bytes --]

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Sharon Kimble <boudiccas@skimble.plus.com> writes:
>
>> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>>
>>> Sharon Kimble <boudiccas@skimble.plus.com> writes:
>>>
>>>> In my gnus setup I have 1 pop3 account, and 3 imap accounts, but only
>>>> one smtp address. How can I have a separate smtp settings so that I am
>>>> able to reply via the address of the email that I've just received?
>>>>
>>>> Thanks
>>>> Sharon.
>>>
>>> The details depend a little bit on the exact program you're using for
>>> sending mail, but generally the rigmarole looks like this (I use
>>> msmtp):
>>
>> I'm using whatever the default is with Debian testing, sorry! Exim4? I
>> don't know what it is, but reportbug is able to send through it.
>>
>> Sharon.
>
> Here's what I've got for mail sending setup, what is your value of
> message-send-mail-function?
>
> (setq message-send-mail-function 'message-send-mail-with-sendmail)
> (setq sendmail-program "msmtp")
>
Thanks Eric, here’s what I have -

--8<---------------cut here---------------start------------->8---
(setq smtpmail-smtp-server "relay.plus.net")
(setq send-mail-function 'smtpmail-send-it)
(setq message-send-mail-function 'smtpmail-send-it)
(require 'smtpmail)

(setq smtpmail-auth-credentials "~/.authinfo")
--8<---------------cut here---------------end--------------->8---

Sharon.
-- 
A taste of linux = http://www.sharons.org.uk
my git repo = https://bitbucket.org/boudiccas/dots
TGmeds = http://www.tgmeds.org.uk
Debian testing, fluxbox 1.3.5, emacs 24.3.93.1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

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

* Re: separate smtps for my accounts
  2014-09-16 18:57       ` Sharon Kimble
@ 2014-09-17  2:17         ` Eric Abrahamsen
  2014-09-24 15:24           ` Ted Zlatanov
  2014-09-17 12:32         ` Rasmus
  1 sibling, 1 reply; 10+ messages in thread
From: Eric Abrahamsen @ 2014-09-17  2:17 UTC (permalink / raw)
  To: ding

Sharon Kimble <boudiccas@skimble.plus.com> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> Sharon Kimble <boudiccas@skimble.plus.com> writes:
>>
>>> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>>>
>>>> Sharon Kimble <boudiccas@skimble.plus.com> writes:
>>>>
>>>>> In my gnus setup I have 1 pop3 account, and 3 imap accounts, but only
>>>>> one smtp address. How can I have a separate smtp settings so that I am
>>>>> able to reply via the address of the email that I've just received?
>>>>>
>>>>> Thanks
>>>>> Sharon.
>>>>
>>>> The details depend a little bit on the exact program you're using for
>>>> sending mail, but generally the rigmarole looks like this (I use
>>>> msmtp):
>>>
>>> I'm using whatever the default is with Debian testing, sorry! Exim4? I
>>> don't know what it is, but reportbug is able to send through it.
>>>
>>> Sharon.
>>
>> Here's what I've got for mail sending setup, what is your value of
>> message-send-mail-function?
>>
>> (setq message-send-mail-function 'message-send-mail-with-sendmail)
>> (setq sendmail-program "msmtp")
>>
> Thanks Eric, here’s what I have -
>
> (setq smtpmail-smtp-server "relay.plus.net")
> (setq send-mail-function 'smtpmail-send-it)
> (setq message-send-mail-function 'smtpmail-send-it)
> (require 'smtpmail)
>
> (setq smtpmail-auth-credentials "~/.authinfo")

I'm not doing what you're doing, so I won't be able to help you
directly, but I'll bet you can find a good solution on this page:

http://www.emacswiki.org/emacs/MultipleSMTPAccounts

Check the section starting "In the recently released Emacs 24.1, one
could utilitize the fact..."

A unified or built-in solution for this would be pretty nice...

E




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

* Re: separate smtps for my accounts
  2014-09-13 22:03   ` Sharon Kimble
  2014-09-14  2:01     ` Eric Abrahamsen
@ 2014-09-17  8:37     ` Eric S Fraga
  1 sibling, 0 replies; 10+ messages in thread
From: Eric S Fraga @ 2014-09-17  8:37 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 982 bytes --]

On Saturday, 13 Sep 2014 at 23:03, Sharon Kimble wrote:

[...]

> I'm using whatever the default is with Debian testing, sorry! Exim4? I
> don't know what it is, but reportbug is able to send through it.

With exim4 (which I find overly complicated), I have no idea how to do
what you want.  

With msmtp, it is easy however.  You define specific gnus-posting-styles
based on groups and define the address for each case, including the
default catch-all case.  In the msmtp configuration, i.e. the .msmtprc
file, you then have an entry for the various servers which matches the
"from" specification with the address specified in gnus.

I can give more specific examples if you end up switching to msmtp but
this has been discussed previously on this list so you may be able to
find examples yourself.

HTH,
eric

-- 
: Eric S Fraga, GnuPG: 0xFFFCF67D
: in Emacs 24.4.50.1 + Ma Gnus v0.12 + evil-git-0469bee
: BBDB version 3.1.2 (2014-05-06 11:45:08 -0500)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 180 bytes --]

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

* Re: separate smtps for my accounts
  2014-09-16 18:57       ` Sharon Kimble
  2014-09-17  2:17         ` Eric Abrahamsen
@ 2014-09-17 12:32         ` Rasmus
  1 sibling, 0 replies; 10+ messages in thread
From: Rasmus @ 2014-09-17 12:32 UTC (permalink / raw)
  To: ding

Hi Sharon,

Sharon Kimble <boudiccas@skimble.plus.com> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>> Here's what I've got for mail sending setup, what is your value of
>> message-send-mail-function?
>>
>> (setq message-send-mail-function 'message-send-mail-with-sendmail)
>> (setq sendmail-program "msmtp")
>>
> Thanks Eric, here’s what I have -
>
> (setq smtpmail-smtp-server "relay.plus.net")
> (setq send-mail-function 'smtpmail-send-it)
> (setq message-send-mail-function 'smtpmail-send-it)
> (require 'smtpmail)

You may be making your life more complicated than necessary.

Must you use a separate program?  Gnus communicates via smtp out of
the box.  I suggest you look into X-Message-SMTP-Method and posting
styles.

Here's my posting style for inspiration.  I have no other mention of
smtp in my init.el.

(setq gnus-posting-styles
      '(((lambda ()
           (rasmus/gnus-posting-style-identify ".*" `("To". ,(regexp-quote "mydom.com")) nil))
         (GCC "nnimap+mail:mydomain/sent")
         (X-Message-SMTP-Method "smtp ssl.mydomain.com 465 rasmus")
         (signature (cookie
                     (expand-file-name "signatures" user-emacs-directory) "" ""))
         (Face (gnus-random-face))
         (eval (setq smtpmail-stream-type 'ssl)))
        ((lambda ()
           (rasmus/gnus-posting-style-identify
            "school" `("To" . ,(regexp-quote "rasmus@school.com"))
            (lambda () (rasmus/message-mailto-test (regexp-quote "school.com")))))
         (address "rasmus@school.com")
         (Face (gnus-convert-png-to-face
                (expand-file-name "school.png" gnus-face-directory)))
         (Organization "school")
         (GCC "nnimap+mail:school/sent")
         (X-Message-SMTP-Method "smtp outlook.com 587 rasmus@school.com")
         (signature "school")
         (eval (setq smtpmail-stream-type nil)))
        ((lambda ()
           (rasmus/gnus-posting-style-identify
            (regexp-opt '("gmx" "gmane" "sunsite" "emacs"))
            `("To" . ,(regexp-quote "rasmus@gmx.us")) 'message-news-p))
         (name "Rasmus")
         (address "rasmus@gmx.us")
         (Organization nil)
         (GCC "nnimap+mail:gmx/sent")
         (X-Message-SMTP-Method "smtp mail.gmx.com 587 rasmus@gmx.us")
         (eval (setq smtpmail-stream-type nil)))))

> (setq smtpmail-auth-credentials "~/.authinfo")

BTW: Emacs can handle .authinfo.gpg out of the box.

Hope it helps,
Rasmus




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

* Re: separate smtps for my accounts
  2014-09-17  2:17         ` Eric Abrahamsen
@ 2014-09-24 15:24           ` Ted Zlatanov
  0 siblings, 0 replies; 10+ messages in thread
From: Ted Zlatanov @ 2014-09-24 15:24 UTC (permalink / raw)
  To: ding

On Wed, 17 Sep 2014 10:17:06 +0800 Eric Abrahamsen <eric@ericabrahamsen.net> wrote: 

EA> A unified or built-in solution for this would be pretty nice...

1) in my ~/.authinfo.gpg

#+begin_src text
machine smtp.gmail.com login ted@px.com port 587 password "pass1"
machine smtp.gmail.com login ted@lifelogs.com password "pass2"
#+end_src

2) I use this function, original author unknown:

#+begin_src lisp
(defun tzz-change-smtp ()
  "Change the SMTP server according to the current from line."
  (save-excursion
    (save-restriction
      (message-narrow-to-headers)
      (let* ((from (message-fetch-field "from"))
             (from-px (string-match "px" from))
             )
        (cond
         (from-px
          (setq smtpmail-smtp-service 587
                smtpmail-smtp-user "ted@px.com"
                smtpmail-smtp-server  "smtp.gmail.com"
                smtpmail-default-smtp-server smtpmail-smtp-server))
         (t
          (setq smtpmail-smtp-service 587
                smtpmail-smtp-user "ted@lifelogs.com"
                smtpmail-smtp-server  "smtp.gmail.com"
                smtpmail-default-smtp-server smtpmail-smtp-server)))))))

(add-hook 'message-send-hook 'tzz-change-smtp)
#+end_src

So basically the `smtpmail-smtp-user' and `smtpmail-smtp-server' are
matched against ~/.authinfo.gpg.

This is essentially what posting-styles is designed for. Does it look
robust enough to add support for it to the posting styles?  Or is it
already supported?  Sorry, I'm a bit out of date on this stuff :)

If we find a solution that works out of the box, we can add it to the
auth-source manual and tell people about it: (info "(auth) Help for users")

Ted




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

end of thread, other threads:[~2014-09-24 15:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-12  0:58 separate smtps for my accounts Sharon Kimble
2014-09-12  2:08 ` Eric Abrahamsen
2014-09-12 15:05   ` Jorge A. Alfaro-Murillo
2014-09-13 22:03   ` Sharon Kimble
2014-09-14  2:01     ` Eric Abrahamsen
2014-09-16 18:57       ` Sharon Kimble
2014-09-17  2:17         ` Eric Abrahamsen
2014-09-24 15:24           ` Ted Zlatanov
2014-09-17 12:32         ` Rasmus
2014-09-17  8:37     ` Eric S Fraga

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 NNTP newsgroup(s).