Discussion:
multiple mail accounts in Gnus
Filipp Gunbin
2014-10-02 14:48:48 UTC
Permalink
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 "***@fastmail.fm"
:stream ssl
:mailbox "Inbox")
(imap :server "outlook.office365.com"
:user "***@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 "***@fastmail.fm")

3) Answering to emails

(setq gnus-posting-styles
'((".*"
(address "***@fastmail.fm")
("X-Message-SMTP-Method" "smtp mail.messagingengine.com 587"))
("nnml:mail.okko"
(address "***@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
Eric Abrahamsen
2014-10-03 02:17:57 UTC
Permalink
Post by Filipp Gunbin
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"
:stream ssl
:mailbox "Inbox")
(imap :server "outlook.office365.com"
: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
3) Answering to emails
(setq gnus-posting-styles
'((".*"
("X-Message-SMTP-Method" "smtp mail.messagingengine.com 587"))
("nnml:mail.okko"
("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.
4) Composing new email
(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)))
(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
Filipp Gunbin
2014-10-03 16:32:12 UTC
Permalink
Eric, thanks for the reply
Post by Eric Abrahamsen
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
Eric Abrahamsen
2014-10-04 02:55:24 UTC
Permalink
Post by Filipp Gunbin
Eric, thanks for the reply
Post by Eric Abrahamsen
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

Loading...