Sunday, November 21, 2010

Gnus - multiple imap accounts on the same server

Quick config snippet for Gnus. I have two primary email accounts -- one on Google Apps for work, and the other just plain gmail for personal. In moving to Gnus, initially I had a problem getting them both to work. The lisp for .gnus is simple. I'm using gnus-secondary-select-methods to configure my mail servers, like this:

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

That works fine but it prompts for usernames and passwords, so I need some entries in my .authinfo file to automate that. Unfortunately, a simple view of that would have me writing a .authinfo like this:


machine imap.gmail.com login     work-email password     work-password port 993
machine imap.gmail.com login personal-email password personal-password port 993

But of course that won't work because both lines get triggered when Gnus tries to access either account, since both are on "imap.gmail.com". In practice I think it means it would just access my work account twice. But, according to Simon Josefsson:
nnimap has solved this problem by letting you use, instead of the server address, the virtual Gnus server name when specifying username/passwords in the authinfo file.
So that means I should be able to change the above to:

machine     work login     work-email password     work-password port 993
machine personal login personal-email password personal-password port 993

However, that didn't work. Gnus acted just as if it didn't recognize either of those and insisted on me authenticating interactively. But, helpful people at gmane.emacs.gnus.general (thanks Tassilo) provided the simple solution. All I had to do was append the "force yes" command to the end of each of those lines, like this:

machine     work login     work-email password     work-password port 993 force yes
machine personal login personal-email password personal-password port 993 force yes

Now it's working fine.

No comments:

Post a Comment