Gnus development mailing list
 help / color / mirror / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: ding@gnus.org
Subject: Re: multiple mail accounts in Gnus
Date: Fri, 03 Oct 2014 10:17:57 +0800	[thread overview]
Message-ID: <87oatt3nhm.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <m2k34ifrxr.fsf@fastmail.fm>

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




  reply	other threads:[~2014-10-03  2:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-02 14:48 Filipp Gunbin
2014-10-03  2:17 ` Eric Abrahamsen [this message]
2014-10-03 16:32   ` Filipp Gunbin
2014-10-04  2:55     ` Eric Abrahamsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87oatt3nhm.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).