Search:  
Gentoo Wiki

SquirrelMail

SquirrelMail is a standards-based webmail package written in PHP. It includes built-in pure PHP support for the IMAP and SMTP protocols, and all pages render in pure HTML 4.0 (with no JavaScript required) for maximum compatibility across browsers. It has very few requirements and is very easy to configure and install. SquirrelMail has all the functionality you would want from an email client, including strong MIME support, address books, and folder manipulation.

Warning: SquirrelMail uses MySQL databases to store address books and this table is created to be (almost) fully accessible for every local connection so it is not really secure (yet).

Contents

Install

Since emerging will auto-magically install it as well, let's emerge it:

emerge squirrelmail

To manually install it or install it to a different directory, do the following (the version numbers may be different though):

webapp-config -I -h domain.tld -d /sqmail squirrelmail 1.4.4

Let's configure squirrelmail so, Change your Organization, Server, and Folder settings for squirrelmail.

cd /var/www/localhost/htdocs/mail/config perl ./conf.pl

I also suggest visiting the SquirrelMail website and looking at the plugins. There are a couple of virtual hosting plugins you may be intersted in. None are required but can make life a little better (as all plugins should do in one way or another).

Now you should be able to login to squirrelmail, again - with your full email address, and use your new webmail setup. Your username is your email address.

Configuration

Basic configuration

This software is rather simple to set up. It comes with it's own ncurses configuration utility. So let's run that now:

cd /var/www/localhost/htdocs/squirrelmail/config
perl conf.pl

You should be presented with a screen showing menu choices allowing you to enter a number. Let's start with Organization Data by pressing 1. As you can see, every option is prefixed with a number, so to edit the option you would type in the corresponding number and enter a new value.

Once you're finished, press "R" to return to the main menu.

Now press "2" to configure the server settings.

Here are what my options look like, and perhaps you are able to extrapolate what yours should be.

Code: Code Sample
General
-------
1.  Domain                 : apparition.ath.cx
2.  Invert Time            : false
3.  Sendmail or SMTP       : Sendmail
IMAP Settings
-------------
4.  IMAP Server            : localhost
5.  IMAP Port              : 993
6.  Authentication type    : login
7.  Secure IMAP (TLS)      : true
8.  Server software        : courier
9.  Delimiter              : detect

As you can see, it's fairly straight forward. I entered my domain name after pressing "1", after pressing "3" I told squirrelmail to use Sendmail as opposed to SMTP. I then pressed "A" to get the IMAP settings available. I changed the port, TLS and server software to match this setup. But wait! We never installed sendmail. Here's the beauty of Postfix, it seamlessly replaces sendmail even creating a link named sendmail in /usr/sbin/ for programs expecting the binary. Pretty clever of Postfix eh? Nothing to worry about.

Once you're done, press "S" to save your settings and then press "Q" to quit the configuration utility.

Configuration for virtual users

Set up the Squirrelmail SQL tables using the following SQL

Code: Squirrelmail Table setup SQL
CREATE DATABASE squirrelmail;

GRANT select,insert,update,delete ON squirrelmail.*
TO Anonymous@localhost IDENTIFIED BY '';

USE squirrelmail;
CREATE TABLE address (
owner varchar(128) DEFAULT '' NOT NULL,
nickname varchar(16) DEFAULT '' NOT NULL,
firstname varchar(128) DEFAULT '' NOT NULL,
lastname varchar(128) DEFAULT '' NOT NULL,
email varchar(128) DEFAULT '' NOT NULL,
label varchar(255),
PRIMARY KEY (owner,nickname),
KEY firstname (firstname,lastname)
);

CREATE TABLE userprefs (
user varchar(128) DEFAULT '' NOT NULL,
prefkey varchar(64) DEFAULT '' NOT NULL,
prefval blob DEFAULT '' NOT NULL,
PRIMARY KEY (user,prefkey)
);

To start the setup run: /var/www/localhost/htdocs/squirrelmail/configure This shows you:

Main Menu --
1.  Organization Preferences
2.  Server Settings
3.  Folder Defaults
4.  General Options
5.  Themes
6.  Address Books (LDAP)
7.  Message of the Day (MOTD)
8.  Plugins
9.  Database
10. Language

D.  Set pre-defined settings for specific IMAP servers

C.  Turn color off
S   Save data
Q   Quit

Then press 9 to enter the database section. Upon doing so, the following will appear. Adjust the DSN entries (1 and 3 below) to the values shown (obviously substituting your actual postfix mysel users password).

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Database
1.  DSN for Address Book   : mysql://postfix:yourpassword@localhost/squirrelmail
2.  Table for Address Book : address

3.  DSN for Preferences    : mysql://postfix:yourpassword@localhost/squirrelmail
4.  Table for Preferences  : userprefs
5.  Field for username     : user
6.  Field for prefs key    : prefkey
7.  Field for prefs value  : prefval

R   Return to Main Menu
C.  Turn color off
S   Save data
Q   Quit

Automating and Finalizing

Point your browser to this address https://192.168.2.2/squirrelmail and login using the same data you have written down in chart 2.1. Just remember to replace the IP in the URL that matches your Server.

Now, you must tell SquirrelMail that you wish to subscribe to various folders. Click on the link "Folders" that runs along the top of the page. Once the new page has loaded, simply highlight the folders listed in the select box such as "INBOX.gentoo and click on the Subscribe button. Refresh your folder listing and you'll see how Procmail has sorted all your email.

Send an email to yourself and receive it... you should know the drill.

All that's left is to add apache to your default runtime:

root@server # rc-update add apache2 default

A note for non-English Squirrelmail setups

If Squirrelmail does not display in the language you configured, this may be due to the following php problem: If php is running in safe mode, it can by default only access environment variables beginning with "PHP_". This breaks the use of the GNU gettext library and will usually result in the Squirrelmail interface displaying in English only. To fix this, make the variables LC_ALL and LANG available to php (the filename of the php config file may differ for your setup):

File: /etc/php/apache2-php4/php.ini
safe_mode_allowed_env_vars=LC_ALL,LANG,LANGUAGE,PHP_

Another possible (but untested) solution is to use the alternative translation method Squirrelmail offers, but the Squirrelmail website disencourages that method for performance reasons.

Testing

Test SquirrelMail by trying to login at http://localhost/squirrelmail . If you get an error about ownership and not being able to edit/create a default_pref, execute the following command: chown -R apache:apache /var/www/localhost/squirrelmail -R

Retrieved from "http://www.gentoo-wiki.info/SquirrelMail"

Last modified: Fri, 05 Sep 2008 10:02:00 +0000 Hits: 1,263