From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/85071 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.gnus.general Subject: Re: multiple mail accounts in Gnus Date: Fri, 03 Oct 2014 10:17:57 +0800 Message-ID: <87oatt3nhm.fsf@ericabrahamsen.net> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1412302816 11888 80.91.229.3 (3 Oct 2014 02:20:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 3 Oct 2014 02:20:16 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M33315@lists.math.uh.edu Fri Oct 03 04:20:11 2014 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XZsTb-000216-3f for ding-account@gmane.org; Fri, 03 Oct 2014 04:20:11 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1XZsRn-00079U-4N; Thu, 02 Oct 2014 21:18:19 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1XZsRl-000793-50 for ding@lists.math.uh.edu; Thu, 02 Oct 2014 21:18:17 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) (envelope-from ) id 1XZsRf-0005Dt-0X for ding@lists.math.uh.edu; Thu, 02 Oct 2014 21:18:12 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]) by quimby.gnus.org with esmtp (Exim 4.80) (envelope-from ) id 1XZsRd-0006tz-1j for ding@gnus.org; Fri, 03 Oct 2014 04:18:09 +0200 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XZsRc-0000xD-NZ for ding@gnus.org; Fri, 03 Oct 2014 04:18:08 +0200 Original-Received: from 123.123.17.134 ([123.123.17.134]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 03 Oct 2014 04:18:08 +0200 Original-Received: from eric by 123.123.17.134 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 03 Oct 2014 04:18:08 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 82 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 123.123.17.134 User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:NFsHD7xerszk9lWhdgmxpXP/zmc= X-Spam-Score: -2.7 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:85071 Archived-At: Filipp Gunbin 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