Pop3 Imap
Pop3 Imap
Objectives
1. Definitions of IMAP, POP3, Exim, Courierauthlib, etc 2. Reconfigure Exim for Maildir delivery 3. Install Courier-authlib 4. Configure and start courier-authlib 5. Test courier-authlib
Objectives
6. Install courier-imap 7. Configure and start courier-imap Test POP3 and IMAP 8. POP3 and IMAP over SSL
IMAP
IMAP is an Internet Message Access Protocol. It is a method of accessing electronic mail messages that are kept on a possibly shared mail server. In other words, it permits a "client" email program to access remote message stores as if they were local. For example, email stored on an IMAP server can be manipulated from a desktop computer at home, a workstation at the office, and a notebook computer while travelling, without the need to transfer messages or files back and forth between these computers. IMAP uses TCP/IP port 143.
POP
Short for Post Office Protocol, a protocol used to retrieve e-mail from a mail server. Most e-mail applications (sometimes called an e-mail client) use the POP protocol, although some can use the newer IMAP (Internet Message Access Protocol). There are two versions of POP. The first, called POP2, became a standard in the mid-80's and requires SMTP to send messages. The newer version, POP3, can be used with or without SMTP. POP3 uses TCP/IP port 110.
POP3 vs IMAP
With IMAP, all your mail stays on the server in multiple folders, some of which you have created. This enables you to connect to any computer and see all your mail and mail folders. In general, IMAP is great if you have a dedicated connection to the Internet or you like to check your mail from various locations. With POP3 you only have one folder, the Inbox folder. When you open your mailbox, new mail is moved from the host server and saved on your computer. If you want to be able to see your old mail messages, you have to go back to the computer where you last opened your mail. With POP3 "leave mail on server" only your email messages are on the server, but with IMAP your email folders are also on the server.
Exim
Exim is an open source mail transfer agent (MTA), which is a program responsible for receiving, routing, and delivering e-mail messages (this type of program is sometimes referred to as an Internet mailer, or a mail server program). MTAs receive e-mail messages and recipient addresses from local users and remote hosts, perform alias creation and forwarding functions, and deliver the messages to their destinations. Exim was developed at the University of Cambridge for the use of Unix systems connected over the Internet. The software can be installed in place of sendmail, the most common MTA for UNIX and Linux systems. In comparison to sendmail, Exim is said to feature more straightforward configuration and task management.
Courier-authlib
Courier is a mail system which includes a number of packages. It has its own MTA. We are interested in only the following components IMAP/POP3 servers and sqwebmail The courier packages now share a single authentication library, courier-authlib. This package is responsible for looking up usernames and passwords
Maildir
Maildir is a widely-used format for storing e-mail that does not require application-level file locking to maintain message integrity as messages are added, moved and deleted. Each message is kept in a separate file with a unique name. All changes are made using atomic filesystem operations so that the filesystem handles file locking concurrency issues. A Maildir is a directory (often named Maildir) with three subdirectories named tmp, new, and cur.
Install Courier-authlib
# cd /usr/ports/security/courier-authlib/ # make When prompted for options on the screen, press the down arrow to highlight the option: [X] AUTH_USERDB Userdb support Press <TAB> to highlight OK, and then <ENTER> to continue. # make install # make clean (optional step - deletes temporary files in 'work' subdir) Total compile time on your machines will be between 10 and 15 minutes.
Test courier-authlib
courier-authlib runs a pool of authentication daemons which perform the actual work; courier-imap and sqwebmail communicate with these daemons via a socket. So the next thing we need to do is to start the daemons. First you need to edit /etc/rc.conf: # vi /etc/rc.conf add the following line: courier_authdaemond_enable="YES" Courier-authlib itself has a single configuration file, /usr/local/etc/authlib/authdaemonrc. For the purposes of this exercise, we will turn on authentication debugging. # cd /usr/local/etc/authlib # vi authdaemonrc change this line: DEBUG_LOGIN=0 to: DEBUG_LOGIN=1
Test courier-authlib
To save resources, you can also configure the authdaemond process not to try any authentication mechanisms which you know you don't need. For example, if all your authentication is only via PAM for Unix system passwords, then you can remove all the others. Save the original line so that your changes look like this: #authmodulelist="authuserdb authvckpw authpam authldap authmysql authpgsql" authmodulelist="authpam" Now we are ready to start the authentication daemons: # /usr/local/etc/rc.d/courier-authdaemond start
Starting courier_authdaemond. # ps auxwww | grep authdaemond ps shows one courierlogger process, and six authdaemond processes (one master, five workers). If you didn't see "Starting courier_authdaemond" then you made a typing error.
Test courier-authlib
You can test the authentication system by itself; the "authtest" command sends requests down the authentication socket, and displays the responses which come back. Test using any Unix login account which already exists on your system. # authtest brian -- find an account called 'brian' # authtest brian foo -- check 'brian' has password 'foo' # authenumerate -- list all accounts Try it also with a non-existent username, and with both the right password and a wrong password for an account, to confirm that passwords are being validated properly. Because we enabled login debugging, you should find that each authentication request generates detailled information in /var/log/debug.log showing how the request is passed to each module in turn. Have a look in this file to confirm: # less /var/log/debug.log
Install courier-imap
Using ports, building courier-imap is straightforward: # cd /usr/ports/mail/courier-imap # make [When prompted for options on the screen, press <TAB> to highlight OK, and then <ENTER> to continue.] # make install # make clean (optional step) Compilation will take 10 to 15 minutes on your machines.