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

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