To connect to password protected servers you need the .authinfo file.
Create it with only read-write rights for the user. Under Unix say
touch ~/.authinfo chmod 600 ~/.authinfo
in a shell. Consider encrypting it (GnusEncryptedAuthInfo).
Add a line for each user like this with following field(s) {where applicable}:
machine HOST login NAME password VALUE port NUMBER
i.e. in following example from John Doe’s ~/.authinfo:
machine imap.gmail.com login john_doe@gmail.com password notapassword port 993
The relevant IMAP fields would map as:
machine → imap.gmail.com ; login → johnDoe@gmail.com ; password → notapassowrd ; port → 993 ;
Optional parameters are (depending on protocol) might include port number (you can also use symbolic names like imap here), force yes and default.
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
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"
== Encrypting passwords It is possible to encrypt the whole file so that Emacs asks a passwords to access it. See GnusEncryptedAuthInfo.