Gnus development mailing list
 help / color / mirror / Atom feed
* multiple mail accounts in Gnus
@ 2014-10-02 14:48 Filipp Gunbin
  2014-10-03  2:17 ` Eric Abrahamsen
  0 siblings, 1 reply; 4+ messages in thread
From: Filipp Gunbin @ 2014-10-02 14:48 UTC (permalink / raw)
  To: ding

Here's my solution to the problem.  I'm not sure I'm doing it right.
Perhaps somebody could suggest me a better option.

I have two accounts - one private and one for work.

1) Get mail from both

(setq gnus-select-method '(nnnil ""))  ; turn off primary select method

(setq gnus-secondary-select-methods '((nnml "")))  ; only mail here

(setq mail-sources '((imap :server "mail.messagingengine.com" 
			   :user "fgunbin@fastmail.fm"
			   :stream ssl 
			   :mailbox "Inbox")
		     (imap :server "outlook.office365.com" 
		     	   :user "fgunbin@playteam.ru"
		     	   :stream ssl)))

In combination with nnmail-split-methods this downloads and spreads new
emails over several nnml groups.

2) Default address and smtp server

(setq smtpmail-smtp-server "mail.messagingengine.com"
      smtpmail-smtp-service 587
      user-mail-address "fgunbin@fastmail.fm")

3) Answering to emails

(setq gnus-posting-styles
      '((".*"
	 (address "fgunbin@fastmail.fm")
	 ("X-Message-SMTP-Method" "smtp mail.messagingengine.com 587"))
	("nnml:mail.okko"
	 (address "fgunbin@okko.tv")
	 ("X-Message-SMTP-Method" "smtp outlook.office365.com 587"))))

This sets appropriate address and SMTP server for a group I'm replying
from.  All work emails are splitted into a single group: nnml:mail.okko,
so we are overriding only for that group.

Before I had also this setting, but it seems to be useless with the
posting styles configuration above.

(setq message-alternative-emails "fgunbin@\\(fastmail.fm\\|okko.tv\\)")

4) Composing new email

This is awkward:

(defun select-mail-address (&optional to subject other-headers continue
				      switch-function yank-action
				      send-actions return-action)
  "Advice that sets the mail address to use"
  (let ((domain (completing-read "From: " '("okko.tv" "fastmail.fm")
				 nil t))) 
    (setq user-mail-address (concat "fgunbin@" domain))))

(advice-add 'compose-mail :before #'select-mail-address)

As written, it _sets_ the user-mail-address to be used from now on.
Other methods for starting message composition may not call compose-mail
and so this hook may not work there.  SMTP server could also be set
here, but generally I don't care much which server I'm using.

-- 
    Filipp




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

* Re: multiple mail accounts in Gnus
  2014-10-02 14:48 multiple mail accounts in Gnus Filipp Gunbin
@ 2014-10-03  2:17 ` Eric Abrahamsen
  2014-10-03 16:32   ` Filipp Gunbin
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Abrahamsen @ 2014-10-03  2:17 UTC (permalink / raw)
  To: ding

Filipp Gunbin <fgunbin@fastmail.fm> writes:

> Here's my solution to the problem.  I'm not sure I'm doing it right.
> Perhaps somebody could suggest me a better option.
>
> I have two accounts - one private and one for work.
>
> 1) Get mail from both
>
> (setq gnus-select-method '(nnnil ""))  ; turn off primary select method
>
> (setq gnus-secondary-select-methods '((nnml "")))  ; only mail here
>
> (setq mail-sources '((imap :server "mail.messagingengine.com" 
> 			   :user "fgunbin@fastmail.fm"
> 			   :stream ssl 
> 			   :mailbox "Inbox")
> 		     (imap :server "outlook.office365.com" 
> 		     	   :user "fgunbin@playteam.ru"
> 		     	   :stream ssl)))
>
> In combination with nnmail-split-methods this downloads and spreads new
> emails over several nnml groups.
>
> 2) Default address and smtp server
>
> (setq smtpmail-smtp-server "mail.messagingengine.com"
>       smtpmail-smtp-service 587
>       user-mail-address "fgunbin@fastmail.fm")
>
> 3) Answering to emails
>
> (setq gnus-posting-styles
>       '((".*"
> 	 (address "fgunbin@fastmail.fm")
> 	 ("X-Message-SMTP-Method" "smtp mail.messagingengine.com 587"))
> 	("nnml:mail.okko"
> 	 (address "fgunbin@okko.tv")
> 	 ("X-Message-SMTP-Method" "smtp outlook.office365.com 587"))))
>
> This sets appropriate address and SMTP server for a group I'm replying
> from.  All work emails are splitted into a single group: nnml:mail.okko,
> so we are overriding only for that group.
>
> Before I had also this setting, but it seems to be useless with the
> posting styles configuration above.
>
> (setq message-alternative-emails "fgunbin@\\(fastmail.fm\\|okko.tv\\)")
>
> 4) Composing new email
>
> This is awkward:
>
> (defun select-mail-address (&optional to subject other-headers continue
> 				      switch-function yank-action
> 				      send-actions return-action)
>   "Advice that sets the mail address to use"
>   (let ((domain (completing-read "From: " '("okko.tv" "fastmail.fm")
> 				 nil t))) 
>     (setq user-mail-address (concat "fgunbin@" domain))))
>
> (advice-add 'compose-mail :before #'select-mail-address)
>
> As written, it _sets_ the user-mail-address to be used from now on.
> Other methods for starting message composition may not call compose-mail
> and so this hook may not work there.  SMTP server could also be set
> here, but generally I don't care much which server I'm using.

This is a general issue with Gnus, and one that probably needs a
generalized built-in solution, but in the meantime what you're doing is
fine. You still want `message-alternative-emails' in addition to posting
styles, because that variable is a little more comprehensive -- it works
for *any* reply, regardless of the group you're replying from (and also
overrides posting styles if there's a conflict).

Lastly, you could take a look at the gnus-alias package in the package
repos. That package also mentions this package:

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

Hope that helps,
Eric




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

* Re: multiple mail accounts in Gnus
  2014-10-03  2:17 ` Eric Abrahamsen
@ 2014-10-03 16:32   ` Filipp Gunbin
  2014-10-04  2:55     ` Eric Abrahamsen
  0 siblings, 1 reply; 4+ messages in thread
From: Filipp Gunbin @ 2014-10-03 16:32 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: ding

Eric, thanks for the reply

On 03/10/2014 06:17 +0400, Eric Abrahamsen wrote:

> This is a general issue with Gnus, and one that probably needs a
> generalized built-in solution, but in the meantime what you're doing is
> fine. You still want `message-alternative-emails' in addition to posting
> styles, because that variable is a little more comprehensive -- it works
> for *any* reply, regardless of the group you're replying from (and also
> overrides posting styles if there's a conflict).

You mean it will work even there are no specific posting styles?  But I
set them up for all groups.

-- 
    Filipp



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

* Re: multiple mail accounts in Gnus
  2014-10-03 16:32   ` Filipp Gunbin
@ 2014-10-04  2:55     ` Eric Abrahamsen
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Abrahamsen @ 2014-10-04  2:55 UTC (permalink / raw)
  To: ding

Filipp Gunbin <fgunbin@fastmail.fm> writes:

> Eric, thanks for the reply
>
> On 03/10/2014 06:17 +0400, Eric Abrahamsen wrote:
>
>> This is a general issue with Gnus, and one that probably needs a
>> generalized built-in solution, but in the meantime what you're doing is
>> fine. You still want `message-alternative-emails' in addition to posting
>> styles, because that variable is a little more comprehensive -- it works
>> for *any* reply, regardless of the group you're replying from (and also
>> overrides posting styles if there's a conflict).
>
> You mean it will work even there are no specific posting styles?  But I
> set them up for all groups.

Sure, you could certainly do it that way, and posting styles is
certainly useful for many things, including composing new messages. But
my feeling is that message-alternative-emails is somehow "safer": it
will always work, even if you haven't set up posting styles for a group,
and 99% of the time the most important thing is simply replying to a
message using the same From: as the To: you received it at.

You'll want posting styles for the other headers and all that, but I do
think it makes sense to use both in conjunction.

Just my opinion!

Eric




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

end of thread, other threads:[~2014-10-04  2:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-02 14:48 multiple mail accounts in Gnus Filipp Gunbin
2014-10-03  2:17 ` Eric Abrahamsen
2014-10-03 16:32   ` Filipp Gunbin
2014-10-04  2:55     ` Eric Abrahamsen

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