To connect to password protected servers you need to store authentication information in one of these files:

encrypted (use this!)
not encrypted
the old format

Thus, simply save your information in ~/.authinfo.gpg and you’re done.

If you use this file for passwords elsewhere, you might be interested in authinfo-copy-password.


Ideally you already have GPG set up on your system. Emacs will ask you to select the recipients for encryption. Pick your own name from the list. This will allow you to save the file without any hassles. If no one is selected, symmetric encryption will be performed. This means that you will have to provide and confirm the password every time you save the file. Don’t do it.


Create the file with only read-write rights for the user:

    chmod 600 ~/.authinfo.gpg

File Format

Add a line for each account like this:

    machine HOST login NAME password VALUE port NUMBER


    machine login password "*secret*"


If you think you provided the correct information in the file, and Gnus asks you for your password as it tries to connect, and Gnus still fails to authenticate, it’s time to check your authinfo file. Use ‘M-x netrc-parse’ and test your file. Perhaps you misplaced some quotes, or you used multibyte Unicode characters. These are problematic because Emacs keeps a cache of the authinfo file in memory. The cache is obfuscated using ‘base64-encode-string’ and ‘rot13-string’. The problem is that base64 requires bytes and will refuse to encode multibyte characters. Unfortunately for you this error messages is surpressed when Gnus tries to connect to servers…

The above is inaccurate as of 2012-04-28; ‘auth-source’ now stashes password caches in a closure, and has no problem with multibyte characters, since it uses ‘buffer-string’.

Different Files for Different Server Methods

You can use different authinfo files for different server methods. For example use this variable:

nntp-authinfo-file for setting the nntp authinfo file

nnimap-authinfo-file for setting the nnimap authinfo file

smtpmail-auth-credentials for setting the smtpmail authinfo file

This is deprecated as of 24.1, ~/.authinfo (or ~/.authinfo.gpg) is used by default, see variable auth-sources.

Connecting to another Box on an Exchange Server

Using the nnimap backend you can connect to another box by giving the domain, username and boxname explicitly:

    machine <mailserver> login "<domain>/<username>/<boxname>" password "secret"