informa
/
3 min read
article

Build a Low-Cost Mail Server, Part 2

Expand a basic FreeBSD e-mail server with virus protection, spam detection, and Webmail access.
Installing and Configuring SquirrelMail

You are almost finished. Adding SquirrelMail to provide Webmail services will top off your server. Install SquirrelMail using the following command:

% /usr/sbin/pkg_add "r squirrelmail
If you watch the messages that FreeBSD shows onscreen, you'll notice that it installs several packages that Squirrelmail depends on, including PHP and the Apache Web server. Read the screen that appears after the SquirrelMail package is installed. It describes configuration actions you will need to take before SquirrelMail will work. To allow access to SquirrelMail in a browser, add an alias in /usr/local/etc/apache/httpd.conf pointing to /usr/local/www/squirrelmail. If the server isn't going to a webserver per se, you can do this by changing the variable DocumentRoot to /usr/local/www/squirrelmail. One dependency that will be installed with SquirrelMail is the scripting language PHP4. This adds several configuration files to /usr/local/etc, including two sample php.ini files. Create a php.ini file for the system as follows:
% cp php.ini-recommended php.ini
Look in your new /usr/local/etc/php.ini and make sure that the following option is set:
file_uploads = On
SquirrelMail has a menu-driven configuration program, accessed by issuing this command:
% cd /usr/local/www/squirrelmail && ./configure
Go through the menu items to configure SquirrelMail's options for your server—for example, the domain name. The menu items are self-explanatory and include examples. Now is a good time to start up Apache and see if your SquirrelMail configuration is any good. First, start Apache:
% /usr/local/sbin/apachectl start
Next, open a Web browser on a second machine on your network and point it to http:///src/configtest.php. Assuming you've done everything right, you should get a screen that looks like this:


Look at the bottom of the sreen for the text "Congratulations, your SquirrelMail setup looks fine to me!" If you see it, click on the "Login now" link down at the bottom of the page. This will take you to the login screen:


By now you should haveve created at least one user other than root. Enter that non-root user login ID and password, and you'll be presented with your in-box:


For everyday Webmail logins using the configuration detailed in this Recipe, your users should point their Web browser to http:/// or http:///. Of course, they should replace "example.com" with the actual server's domain name. As with the other daemons we've installed, we want Apache to start automatically every time the system boots. So once more, open /etc/rc.conf in an editor, and add these two lines:
# Automatically start apache on system boot.
apache_enable="YES"

Congratulation, you now have an e-mail server that provides SMTP, POP, and IMAP servers, plus anti-virus and spam filtering, and that is accessible by popular e-mail clients such as Outlook, Mozilla Thunderbird, and Webmail.

That said, we've barely scratched the surface of the functionality offered by each of these programs. I encourage you to delve into their configuration files and the available literature to gain a better understanding of the systems, as well as to learn how to tweak them to best serve your customers' needs.


This is Part 2 of a two-part TechBuilder Recipe. Part 1 shows how how to create a secure, basic e-mail server for SMBs by using three open-source programs: FreeBSD, Postfix, and Dovecot.

DAVID S. MARKOWITZ is a computer network and integration consultant who serves SMBs and home users in the Philadelphia area.