Linux

Configure IT Quick: Set up a POP3 server on Linux with Qpopper

Install Qpopper with these quick and easy steps.

When you set up Sendmail or any standard SMTP server, it's important to remember that it only transports messages between your Linux machine and other mail servers. For your users to retrieve their messages, you will need to set up either a POP3 or IMAP service. One common POP3 implementation, Qpopper, can be installed and set up quickly and easily. Just follow these simple steps.

Did you miss the previous Sendmail articles?
Catch up on your reading here:
"Setting up a Sendmail server on Linux"
"Configuring a robust Sendmail server on Linux"
"Setting up Sendmail to host multiple domains"


Installing Qpopper with Sendmail
For the Qpopper installation steps described in this article, I will assume that you've already installed Sendmail. However, Qpopper will interface seamlessly with any other standard SMTP server.

To begin, download the latest source package, qpopper4.0.3.tar.gz, from the Qpopper Web site. You will also find documentation and software archives on this site. After downloading the distribution, you will need to extract it with the command tar xpfz. Change into the newly created qpopper4.0.3 directory and execute ./configure, make, and then make install.

If you know ahead of time that you will need something other than the default installation, be sure to read the documentation to find all the compilation-time options. For instance, you may prefer to run Qpopper as a stand-alone daemon instead of running it from inetd or xinetd. To do so, you'd need to run ./configure with the --enable-standalone option.

When running Qpopper as a stand-alone daemon, you will need to create a script to start the popper service on boot. Unless you're installing from a distribution-specific archive such as an RPM or DEB, Qpopper will install into /usr/local/lib by default. If you are installing from source, you will also need to add the following line to /etc/inetd.conf:
   pop3 stream tcp nowait root /usr/local/lib/popper qpopper -s

Alternatively, if you are using xinetd.conf, which is the default on newer Red Hat 7.x installations, be sure to create a file called pop3 in /etc/xinetd.d/ that contains the following:
   service pop3
   {
   socket_type  =  stream
   protocol  =  tcp
   wait  =  no    
   user  =  root
   server  =  /usr/local/lib/popper
   server_args  =  qpopper -s
   port  =  110    
   }


When adding a new service, always check your firewalling rulesets and /etc/hosts.allow file. Your firewall should allow incoming TCP requests directed at port 110, which is the POP3 port, and your hosts.allow should have a line similar to popper: ALL. Also with Red Hat, check /etc/xinetd.d/ and verify that there is not already a reference to a POP3 server. Through a standard installation option, it's possible to have it preconfigured, so if you are adding Qpopper at a later date, make sure to remove any references like /etc/xinetd.d/ipop3 from the xinetd daemon.

Setting up Qpopper
Once you've installed Qpopper, you'll need to start the service. If you are using inetd or xinetd, simply restart the inetd or xinetd daemon by executing kill –HUP <PID>. You can identify the process ID (PID) by running ps aux | grep inet.

If you have installed Qpopper to run in stand-alone mode, you'll need to execute the script you created by placing the line popper –S in /etc/init.d/pop3 , for example. The –S flag tells Qpopper to run in Server mode which can help your server’s I/O performance. When not in Server mode, Qpopper will copy the mail spool file prior to accessing it and then copy it back after making adjustments, such as e-mail deletion. In Server mode, Qpopper scans the spool instead of copying it and works directly from it during a user’s session. This frees up valuable CPU time and decreases hard drive accesses, which is especially important for POP3 servers supporting a large client base.

Table 1 shows a list of command options you can use when running a POP3 server. For instance, you can telnet to port 110 of your server, log in manually, and delete oversize messages. Having a solid understanding of these options also helps to quickly troubleshoot user e-mail issues.

Table 1
USER Enter your user ID after this command, i.e., USER webmaster.
PASS Enter the password for the account in the form PASS password.
QUIT This command ends the current session and deletes marked mail.
LIST List messages and their size with this command.
RETR When passed a message number, this command retrieves a specific e-mail.
DELE This command deletes a specified e-mail when passed a message number.
TOP This shows the top N lines in a specific e-mail (TOP <msg #> <# lines>).

Qpopper relies on standard system authentication mechanisms as utilized by /etc/passwd and /etc/shadow. So, to have POP3 services available to users, it's necessary to add them to the local system. Since you should already be running a mail transport agent such as Sendmail, the odds are this has already been done.

Troubleshooting Qpopper
As with any service you install and run for the first time, there will probably be a few problems. A great way to make sure the server will respond to POP3 requests is to telnet to the server on port 110. You might want to try this both locally and from a remote site. An example of what the command line would look like when doing this kind of test can be seen here.

If you have a large number of users connecting to your server to get their e-mail, you may also need to increase the inetd timeout value by changing the nowait value in the following line:
 pop3 stream tcp nowait.400 root /usr/local/lib/popper qpopper -s

This will prevent Qpopper from thinking it is looping when numerous sessions are opened around the same time. You can tell that you need to change the timeout value that I described above when an entry appears in your log stating that the service is looping.

Another issue that is often raised with larger sites is that of the pop lock. A pop lock is a file that is created when a client opens a POP3 session to the server. This prevents other connections from modifying the mailbox. Sometimes, a user will disconnect ungracefully and Qpopper will fail to remove the temporary spool file it created for the session. This is usually found in the form of .user.pop in the /var/spool directory. The server will usually check for old pop locks and remove them; however, in rare cases, the administrator might need to manually remove these files to allow POP3 access again.

Summing up
Adding POP3 services to your Sendmail server is an important step in providing full e-mail capabilities to your users. With Qpopper, this task can be a fairly easy one. It's quick to download, install, and get up and running. It also works just as well with other standard SMTP servers.

Have a comment or a question?
·        We look forward to getting your input and hearing your experiences regarding this topic. Post a comment or a question about this article.

 
0 comments

Editor's Picks