ONLamp.com
oreilly.comSafari Books Online.Conferences.

advertisement


SquirrelMail, a Web-Based Mail Server

by Glenn Graham
10/24/2002

Client-based Mail Vs. Web-based Mail: A Case in Point

Historically, email has been the primary source of Internet communications. First there were text-based programs such as elm, pine, and mutt (for Unix). With the rise of Windows, email software such as Eudora, Netscape, and Outlook Express took the stage. All of these programs use the POP3 protocol to download messages from a remote server to the local drive.

As people (and laptops) become increasingly mobile, email solutions have become more demanding. Road warriors are tired of spending hours in hotel rooms configuring their email software.

Last year while traveling through Southern California, I stayed at a hotel that offered high-speed access. I connected my laptop to their network, attempted to send a message, and found my home (SMTP) settings wouldn't work. Next I tried changing my setting to the hotel's network, however it wouldn't accept outgoing connections. Luckily I had root access to my home system and was able to configure it to accept my SMTP request. What would an average user have done that, though?

Enter Webmail. It's simple, easy, and attractive to the average user. It doesn't require software (beyond a browser), configuration or headaches. Simply log in to the Web site and read your mail. This goes a long way to explain the popularity of advertising-supported services from major Internet companies.

The Application

I started my search for a Webmail solution at Freshmeat. After sifting through over 65 programs, I stumbled across SquirrelMail. It didn't have fancy screenshots, but to my surprise, had everything I needed. It's easy to install, runs right out of the box, and my clients love it. What else could I ask for?

SquirrelMail runs under Apache with PHP4 support installed. It requires sendmail and imapd running via inetd. In the event you need to run a database, you might consider compiling PHP with MySQL support. Most commercial systems already have these features built in. (If your Apache server hasn't already been built with PHP, see Darrell Brogdon's article on the subject, or read the PHP support documentation in the INSTALL file.)

SquirrelMail polls the mail queue, /var/mail via imapd and parses the output via PHP to HTML using the Apache server. Authentication takes place within the /etc/passwd file when the user logs in with a matching username and password. The administrator must add an entry for each user. (Note: It's not yet possible to add accounts through the Web interface.)

Building and Installing Under FreeBSD 4.6.2-RELEASE (Latest version)

Before installing SquirrelMail, carefully read the documentation on their site. It outlines system and software requirements. Before installation, you must have the following components installed and operational:

  • Apache with PHP support (PHP4). Under FreeBSD, install PHP4 from the ports collection. Optionally, PHP4 may be downloaded from http://www.php.net/

  • sendmail version 8.9.1 or later

  • imapd running from inetd. Under FreeBSD install cyrus-imapd from the ports collection

After that, you're ready to install SquirrelMail.

  1. First, download the installation tarball and untar it to /usr/src/.

  2. Next, read the INSTALL file, noting the PHP compilation instructions. The installation doc is self-explanatory. If you're building PHP from source, though, you may wish to use either:

    ./configure --enable-track-vars --enable-force-cgi-redirect 
                --with-gettext

    or

    ./configure --with-apxs=/usr/local/sbin/apxs --with-mysql
  3. Now, run the ./configure script. Figure 1 below shows an example.


    Figure 1: An example configuration screen

  4. Remember to save your changes.

  5. Move the directory structure (./squirrelmail/) to the DocumentRoot directory from which you wish to serve SquirrelMail. The FreeBSD default is /usr/local/www/data/.

  6. Create a directory to store your attachments.

    mkdir /usr/local/www/data/squirrelmail/attachments/
  7. Change the mode of the data and attachments directories to 755.

    chmod 755 /usr/local/www/data/squirrelmail/data/
    chmod 755 /usr/local/www/data/squirrelmail/attachments/
  8. Edit your php.ini file to enable cookies, by setting session.use_cookies to 1.

  9. Enable imapd via /etc/inetd.conf. Add or modify the appropriate line to read:

    imap4 stream tcp nowait root /usr/local/libexec/imapd imapd
  10. Set your imapd security to allow only connections from the localhost. This may be accomplished through tcpwrappers via /etc/hosts.allow, or by building a custom firewall rule. (Note: If you do not have imapd running, SquirrelMail will not function. Instead, you'll see PHP code in your browser.)

    The appropriate entries in /etc/hosts.allow are:

    # Imapd
    imapd : 127.0.0.1 : allow
    imapd : ALL : deny

Logging In and Testing for the First Time

Before logging in to test the system, remember to restart your Apache server. To test your setup, visit the URL http://YourServer.Com/squirrelmail/index.php. You should see a login window resembling Figure 2.


Figure 2: The login window

To log in, simply enter a valid username and password for an existing email account on your system. As seen in Figure 3, the resulting page will show the contents of the default mail folder. You can click on the image for a larger view.

Click for larger view
Figure 3: The mail folder view

Before using SquirrelMail, remember to click on the options menu and edit (at a minimum) personal information containing your email address, signature, and other preferences.

It's a Nice Package

SquirrelMail is robust and featureful. For example, it effectively blocks HTML images embedded in mail from being downloaded to your desktop without permission. This is a customizable feature available under the options menu. Any unauthorized images will be replaced with a security block.

SquirrelMail also performs well. My first installation used a 200 MHz box with only 64MB of RAM. Although fine for development and testing, it was hardly powerful enough to run the application to serve several users at once. Within a day I upgraded the server to a 500 MHz machine with 128 megabytes of RAM and an ultra fast SCSI drive. The system comfortably accommodates 75 to 100 simultaneous logins without any noticeable loss to performance. The processor utilization averages between 30 to 40 percent.

As users become more and more finicky about the level of service they receive from providers, ISPs are under increased pressure to provide the access their clients demand. If you operate an ISP and don't support Webmail, perhaps it is time to start. SquirrelMail is an excellent solution.

Resources:

Glenn Graham has been working with telecommunications since 1977.


Return to ONLamp.com.



Sponsored by: