Multiple email accounts from the same server in Emacs Gnus

2

2

I'm trying to set up Gnus to use both my gmail accounts but I can only ever get one at a time to show up in the list of folders.

(setq gnus-select-method '(nnimap "work@mywork.org"
                            (nnimap-address "secure.emailsrvr.com")
                            (nnimap-server-port 993)
                            (nnimap-stream ssl)))

(setq gnus-secondary-select-methods
      '((nnimap "myfirstaddress@gmail.com"
                (nnimap-address "imap.gmail.com")
                (nnimap-server-port 993)
                (nnimap-stream ssl))
        (nnimap "mysecondaddress@gmail.com"
                (nnimap-address "imap.gmail.com")
                (nnimap-server-port 993)
                (nnimap-stream ssl))))

That is the relevant portions of my .gnus file. It prompts me for three username passwords on startup. After I enter all three, I can access my work account and the gmail account that I enter the creds for second. This is really annoying! Any ideas?

baudtack

Posted 2009-12-23T07:20:36.000

Reputation: 173

Answers

2

Use 'foreign' servers instead of secondary servers. I have gnus set up as follows:

(setq gnus-select-method '(nntp "127.0.0.1"))

To set up the foreign server, go to your Gnus Group buffer and hit the '^' key to go to the server list. Here you can add a new "server", which can be an alias for a real server, by hitting 'a'. For example, I have a server defined with the following attributes:

(nnimap "foobar"
    (nnimap-address "192.168.1.101")
    (nnimap-server-port 143)
    (nnimap-list-pattern
     ("INBOX" "*"))
    (nnimap-stream network)
    (nnimap-authenticator login)
    (nnimap-authinfo-file "~/.authinfo")
    (nnimap-expunge-on-close always)
    (gnus-check-new-newsgroups nil))

I can add a second one, with similar attributes:

(nnimap "baz"
    (nnimap-address "192.168.1.101")
    (nnimap-server-port 143)
    (nnimap-list-pattern
     ("INBOX" "*"))
    (nnimap-stream network)
    (nnimap-authenticator login)
    (nnimap-expunge-on-close never)
    (nnimap-authinfo-file "~/.authinfo")
    (gnus-check-new-newsgroups nil))

in my ~/.authinfo file I have:

machine baz login bazzy.mcbaz force yes port 143
machine foobar login foobar password FooB@r force yes port 143

So one of them has the password and one doesn't. Also, the authinfo file defines what the login ID is.

Joe Casadonte

Posted 2009-12-23T07:20:36.000

Reputation: 3 945

Where you say "For example, I have a server defined with the following attributes:" can you be more specific. Where have you defined these and using what list? – RichieHH – 2010-07-27T15:38:24.040

@richard: while on the screen where you went with ^, hit e. You'd be given the chance to set-up the server. Just make sure you never delete .newsrc.eld because changes are saved there. – None – 2011-02-26T13:24:40.523

1

(Sorry for my delay in answering.) It seems the accepted answer doesn't solve the problem of saving both passwords. That seems a limitation of ~/.authinfo which stores the passwords. To get around that, create different hostnames and use your hosts file to point to the same gmail host. For example:

machine imap.gmail1.com login sunda@gmail.com password soup
machine smtp.gmail1.com login sunda@gmail.com 587 password soup

machine imap.gmail2.com login sunda2@gmail.com password soup2
machine smtp.gmail2.com login sunda2@gmail.com 587 password soup2

Notice that this also frees you from using foreign servers, since GNUS will consider gmail1.com as one source and gmail2.com as another source.

Here's how your set up can be:

(setq gnus-select-method '(nntp "news.server.some.where"))
(setq gnus-secondary-select-methods 
      '((nnimap "imap.gmail1.com"
                (nnimap-address "imap.gmail1.com")
                (nnimap-server-port 993)
                (nnimap-stream ssl))
        (nnimap "imap.gmail2.com"
                (nnimap-address "imap.gmail2.com")
                (nnimap-server-port 993)
                (nnimap-stream ssl))
        ))

user928330

Posted 2009-12-23T07:20:36.000

Reputation: 11