IlohaMail On Your ISPConfig Server Within 10 Easy Steps

Want to support HowtoForge? Become a subscriber!
 
Submitted by Hans (Contact Author) (Forums) on Fri, 2006-09-22 19:54. :: ISPConfig | Control Panels | Other

ILOHAMAIL On Your ISPConfig Server Within 10 Easy Steps

ilohamail

IlohaMail:
Version 1.0
Author: <hans> [at] bb-hosting [dot] org>
Last edited 22/09/2006

IlohaMail comes with clear instructions, but with this how to, i like to explain how to get it working on our Perfect server with ISPConfig.

This how to will help you to setup IlohaMail without SSL. When you are finished, you have a nice webmailclient at URL http://webmail.myhostingcompany.tld.
For myhostingcompany.tld, use your own domain name of course.

Step 3 is only necessary if you like the extra functions of IlohaMail, like the calendar/scheduler.
In this how to, I will use just as an example:

- IlohaMail-0.8.14-rc3
- I assume that this is your first setup for IlohaMail, this is not an update!
- Website: http://webmail.myhostingcompany.tld
- Your full hostname: server1.myhostingcompany.tld
- Website number within ISPConfig: web1
- Your webs are stored under /var/www
- MySQL database: web_db1
- MySQL username: web1_u1
- MySQL password: mypassword

Here we go:

Step 1 - Create a website

In ISPConfig, create a website via “New site” in the main menu.
On the tab called “Basis” use webmail for the hostname and myhostingcompany.tld for the domain name. Enable MySQL and PHP scripts for this website but disable PHP Safe Mode.

Step 2 – Create a Administator user for the website

In ISPConfig, create a Administrator user, so you can upload the website later via FTP:
In the main menu select “ISP Manager”, select your new website called webmail.myhostingcompany.tld in the structure tree and press the tab “User and Email”.
Press “new” and define a new user and its email address. Give this user administrator rights and press “Save”.

Step 3 - Create a MySQL database for the website:

Click on the tab called “Options” and create a new database for the website.
ISPConfig will show you:

Database name: web1_db1 (example)
Database user: web1_u1 (example)

Then you define a password for the Database user and press “Save”.

Step 4 – Download IlohaMail

You can download IlohaMail from URL http://ilohamail.org/main.php?page=Downloads to your own desktop computer.

At the moment there are two versions available:
IlohaMail-0.8.14-rc3, which is the current and stable version.
IlohaMail-0.9, which is the development version.
Although version 0.9 has the most features, I do recommend the 0.8.14-rc3 version for a production environment.

After downloading IlohaMail, extract it to the filefolder of your choice.

Step 5 – Configure IlohaMail for our ISPConfig server

Note: you can make a lot of settings, I will only mention the ones who are important for a basic setup.
Browse to your extracted IlohaMail file folder.
In that folder, open the conf folder.

Modifications to make in file conf/login.php:

In this file, you will find a line with:
$default_host = "";
Change this into the full hostname of your server, like:
$default_host = "server1.myhostingcompany.tld";

The default port for IlohaMail is IMAP over port 143.
If you want to use pop3 instead of IMAP change the line:
$default_port = 143;
into:
$default_port = 110;

We also hide some options of the login screen:

$hide_host = 1;
$hide_protocol = 1;
$hide_rootdir = 1;
$hide_lang = 1;


Note: value 1 = hide, value 0 = show

The line: $logout_url = "index.php"; tells us where to go, when a user logs out.
You can here define the file/URL of your choice.

You can also change the line
$VDOMAIN_DETECT["domain1.com"] = "mail.domain1.com";
Into
$VDOMAIN_DETECT["domain1.com"] = "server1.myhostingcompany.tld";

And the line
$VDOMAIN_DETECT["domain2.net"] = "mail.domain2.net";
into:
$VDOMAIN_DETECT["domain2.net"] = "server1.myhostingcompany.tld";


Modifications to make in file /conf/conf.php:

As we want to use IlohaMail with all the functions, using the MySQL database, we have to change the line:
$backend = "FS";
into
$backend = "MySQL";

To enable the calendar function and bookmarks use value = 0
To disable the calendar function and bookmarks use value = 1

$DISABLE_CALENDAR = 0;
$DISABLE_BOOKMARKS = 0;


You can tell your mailusers where to report SPAM by changing the line:
$report_spam_to="";
into
$report_spam_to="username@myhostingcompany.tld";

(Define an existing email address on your domain, where users can report spam).

Define your SMTP server.
At this point you can choose between “Courier”and “Sendmail”.
If you use Postfix, leave the line $SMTP_TYPE = "sendmail"; just as it is!


Modifications to make in file conf/db_conf.php

Change the lines:

$DB_HOST="";
$DB_USER="";
$DB_PASSWORD="";


into:

$DB_HOST="localhost";
$DB_USER="web1_u1";
$DB_PASSWORD="mypassword";


(The password as defined at STEP 3).


STEP 6 – mySQL database

In the mySQL directory in the IlohaMail filefolder, you will find a file called sql.
You can use this file to create the tables of the mySQL database.
In this example, I do this with phpMyAdmin.
You can access your database via your Internet browser via URL http://webmail.yourhostingcompany.tld:81/phpmyadmin/

If you do not have phpMyAdmin installed, you can download it at http://www.ispconfig.org/downloads.htm

Login into phpMyAdmin with the mySQL user account as mentioned/defined at STEP 3.

In phpMyAdmin:
- select your database
- select the SQL icon to start a query
- choose your sql file In the mySQL directory in the IlohaMail filefolder and press “Start”
- You can exit phpMyAdmin


STEP 7 – uploading IlohaMail

Now, you can upload IlohaMail, using your favourite FTP-client.
URL: ftp://webmail.myhostingcompany/web
username and password as defined at STEP 2.


STEP 8 – making the DATA directory read/writeable for Apache

Login to you server as root.
Perform the commands:

cd /var/www/web1/web

(web1 is just an example and must be the same web number as mentioned at STEP 3).

dir

(Now you will see the data directory).

Give web server process read/write privileges to all folders in the data directory:

chown -R www-data:www-data data

(This is how it workes on Debian Linux, other distros might differ).

STEP 9 – access your new webmailclient

Now you can point to your new webmail client with your favourite browser.
The address according my how to is:
http://webmail.myhostingcompany.tld

You can login with any valid e-mailaccount (username/password) combination.
Note: do not use alias@domain.tld as in the Uebimiau package provided by ISPConfig.
Only use the username and password.

After your first login you should make some settings before you start using IlohaMail.
Here, the first thing you have to do is define your identity.
You can define more than one identity for an email address but you need at least one.

STEP 10 – customizing IlohaMail

You can change the default colours of IlohaMail.
To change the colours, the only thing you have to do is open the file /var/www/web1/web/source/themes/default/override.inc and change the colours you want by changing the values. (Web1 is just my example).

More information about IlohaMail:
http://ilohamail.org/main.php



Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by necromncr (registered user) on Tue, 2008-10-28 22:47.
Well, I did some tweaking to IlohaMail that allows me to login using email address instead of username. Here is the procedure:

1)

Setup a new MySQL username for accessing db_ispconfig database. For example, let's say it will be ilohamail. I did this step using phpmyadmin as root user. DO NOT MAKE ANY PRIVILEGES FOR ACCESSING ISPConfig's DATABASE YET!

2)

Add privileges to ilohamail user for certain ISPConfig tables and their fields:

GRANT SELECT ( `doc_id` , `user_username` , `user_emailalias` , `user_email`) ON `db_ispconfig`.`isp_isp_user` TO 'ilohamail'@'localhost';

GRANT SELECT ON `db_ispconfig`.`isp_dep` TO 'ilohamail'@'localhost';

GRANT SELECT ( `doc_id` , `doctype_id` , `web_domain`) ON db_ispconfig`.`isp_isp_web` TO 'ilohamail'@'localhost'; 

This will enable IlohaMail access to only username - hostname parts of the tables and not any further info. If you named your database otherwise than db_ispconfig be sure to change that.

3)

Change ./conf/db_config.php and add following lines:

$DB_ISP_HOST="localhost";
$DB_ISP_USER="ilohamail";
$DB_ISP_NAME="db_ispconfig";
$DB_ISP_PASSWORD="<password you created in step 1>";

4)

Change ./conf/conf.php and add this:

$ISP=1

Put it somewhere into php tags (and not at the end of the file!)

5)

Copy include/idba.MySQL.inc into include/idba_isp.MySQL.inc

cp include/idba.MySQL.inc include/idba_isp.MySQL.inc

6)

Open include/idba_isp.MySQL.inc and replace all:

$DB_HOST, $DB_USER, $DB_PASSWORD and $DB_NAME with

$DB_ISP_HOST, $DB_ISP_USER, $DB_ISP_PASSWORD, $DB_ISP_NAME

Leave $DB_PERSISTENT as it is.

7)

Open source/index.php. 

Look for includes (lines 51+). Add the following after include_once("../conf/login.php") :

// check if we're in ISP config mode
if ($ISP) {
    include_once("../conf/db_conf.php");
    include_once("../include/idba_isp.MySQL.inc");
}

Find this lines at around line 110:

        //attempt to initiate session
        if ($user && $password && $host){
                include("../include/icl.inc");
                $user_name = $user;


Change it into:

    //attempt to initiate session
    if ($user && $password && $host){
        include("../include/icl.inc");

        if (($ISP) && (strpos($user,'@')!==false)) {
            $db = new idba_isp_obj;
            // make connection to ISP config database. BE SURE YOU HAVE SECURED ACCESS TO THE DATABASE FIRST!
            if ($db->connect()) {
                $sql = "SELECT user.user_username "
                            ."FROM isp_isp_user user, isp_dep dep, isp_isp_web web "
                            ."WHERE user.doc_id=child_doc_id "
                            ." AND dep.child_doctype_id=1014 "
                            ." AND web.doc_id=dep.parent_doc_id "
                            ." AND (CONCAT(user.user_email,'@',web.web_domain)='$user')";
                $result = $db->query($sql);
                if (($result) && ($db->num_rows($result)>0)){
                    $user = $db->result($result, 0, "user_username");
                }
            }
        }

        $user_name = $user;

Looking thru my code I think this should be enough. You can try logging into your IlohaMail using your mail for login and your password. It should work with your primary email only - aliases wont work.