Roundcube Community Forum
SVN Releases => SVN Discussion => Topic started by: Bcrosswize on May 16, 2007, 06:46:25 PM
-
Round Cube Webmail // give me a min.. need to catch my breath… “WoW… just WoW†Great Job you guys.
This tutorial assumes you have Server 2003 R2, Apache, PHP5, MySQL5, hMailServer, and Active Directory already setup.
Notes: On my server I have 2 harddrives.
HD1 is split into 2 partitions… C: and D:
HD2 E:
C:= windows OS
D:= installed 3 party programs (IE: D:\PHP5, D:\www for apache etc) You may need to change the D: references according to your setup.
E:= mail storage.
Scenario
-----------------------------
We have 2 different computers.
Machine 1(referred to as “PDC†in this tutorial: Primary Domain Controller) has an address of 192.168.1.254 This is the ldap3 or Active Directory server.
Machine 2(referred to as “Mail Machineâ€ÂÂ): This machine runs www, mail, Round Cube, MySQL, and has an internal address of 192.168.1.253. It also has an external address that DNS and MX records point to. Thats 2 network cards. :) I will be accessing Active Directory on "PDC"(192.168.1.254 remote machine) from "Mail Machine"(192.168.1.253 local machine)
Lets say my domain is for an elementary school.
Webpage is http://southtown.k12.mo.us // DNS points to my external address of "Mail Machine"
My mail comes to ImUrHuckleBerry@southtown.k12.mo.us // MX records point to external address of "Mail Machine"
"PDC" (Server 2003) Domain:= southtown.k12.mo.us // The 192.168.1.254 "PDC" Machine
Added a container to Active Directory:= Southtown School District
Added containers to the Active Directory Southtown School District container:= Management, Instructors, Tech Dept, Students
Added users to each of these new containers.
Containers and users in the Active Directory on "PDC" look like this
This is shown in case the pic below is not available.
-----------------------------
Southtown School Disctict
Management
Bob D Boss
Instructors
Teach U
Teach Mii
Teach Et
Tech Dept
ImUrHuckleBerry
Students
Joe Hack
Jack Slap
Will Slash
-----------------------------
(http://www.imagehosting.com/out.php/i630331_ActiveDirectory.gif)
We are finished with setup of “PDC†containers/users. We will now be working on “Mail Machine†for most of the remainder of this tutorial.
-
Didn’t want roundcube in htdocs so I made these mods.
Apache install created the D:\www\
Create a new dir:= D:\www\utils // Web utilities (IE: phpMyAdmin etc)
Create a new dir:= D:\www\utils\web_pass // htpasswd
Open command prompt to D:\www\bin and type
htpasswd –c htpasswd.txt admin
enter the password 2 times.
Close command prompt then move D:\www\bin\htpasswd.txt to D:\www\utils\web_pass\
Create a new dir:= D:\www\logs\roundcube
Create a new dir:= D:\www\logs\roundcube\temp // This is where your log and temp files for roundcube will be.
Open apache’s config file:= httpd.conf and search for and type
# Change 01/01/07
Alias /mail “D:/www/utils/mailâ€ÂÂ
Order allow,deny
Allow from all
AllowOverride AuthConfig
AuthName “Restricted Area!â€ÂÂ
AuthType Basic
AuthUserFile D:\www\utils\web_pass\htpasswd.txt
Require user admin // username you have in htpasswd.txt
Just before
Notes: This will give you password protection until you have this up and running correctly.
Require user admin should correlate to the username you made in htpasswd.txt
Downloaded 557.tar.gz from http://roundcube.tobix.org/
Extracted to D:\www\utils\mail
Rename D:\www\utils\mail\.htaccess to 1.htaccess /* error problem if not
Make a copy of D:\www\utils\mail\config\db.inc.php.dist Rename to db.inc.php
Make a copy of D:\www\utils\mail\config\main.inc.php.dist Rename to main.inc.php
-
We need to create the roundcubemail database and roundcube user.
Open a command prompt window and type
mysql –u root –p
Enter password
> CREATE DATABASE roundcubemail DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
> GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcube@localhost
IDENTIFIED BY ‘password’;
> quit
There are problems with D:\www\utils\mail\mysql5.initial.sql
Some variables needed to be null to work correctly.
Attached is an updated mysql5.initial.sql file. Compare this to the original if your interested.
Open a command prompt window and cd to D:\www\utils\mail\SQL then type
Mysql –u root –p roundcubemail < mysql5.initial.sql
Enter password
Notes: this mysql5.initial.sql is modified for the Advanced Address Book. You can compare this and the original and delete the entries if needed.
-
dp.inc.php
-----------------------------
Open D:\www\utils\mail\config\db.inc.php with your fav editor and change
$rcmail_config[‘db_dsnw’] = ‘mysqli://roundcube:pass@localhost/roundcubemail’;
Save and Close
Notes: mysqli is the php5 driver
Use the same username(roundcube), password(pass) and database name that you made in the MySQL setup.
main.inc.php
-----------------------------
Open D:\www\utils\mail\config\main.inc.php with your fav editor and change
$rcmail_config['enable_caching'] = FALSE;
$rcmail_config['default_host'] = 'localhost';
$rcmail_config['username_domain'] = 'southtown.k12.mo.us';
$rcmail_config['smtp_server'] = 'localhost'; // Note if left blank it uses PHP to mail...My mail was courrupt
$rcmail_config['temp_dir'] = 'D:/www/logs/roundcube/temp/'; // very important... temp not right, no log files
$rcmail_config['log_dir'] = 'D:/www/logs/roundcube/'; // very important for trouble shooting your gig
$rcmail_config['useragent'] = 'Southtown E-Mail';
$rcmail_config['product_name'] = 'Southtown E-Mail';
$rcmail_config['drafts_mbox'] = 'Drafts'; // Outlook Replica
$rcmail_config['junk_mbox'] = 'Spam'; // Outlook Replica
$rcmail_config['sent_mbox'] = 'Sent Items'; // Outlook Replica
$rcmail_config['trash_mbox'] = 'Deleted Items'; // Outlook Replica
$rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent Items', 'Spam', 'Deleted Items'); // Outlook Replica
$rcmail_config['ldap_public']['Southtown'] = array( // ldap setup
'name' => 'Southtown School', // name shown in roundcube address book
'hosts' => array('192.168.1.254'), // Server 2003 with Active Directory
'port' => 389, // Server 2003 ldap port
'version' => 3, // added for ldap version
'user_id' => 'ImUrHuckleBerry', // added for ldap username
'pwd' => 'SuperCrypticPass', // added for ldap password
'base_dn' => 'OU=Southtown School District,DC=southtown,DC=k12,DC=mo,DC=us', // Active Directory Setup
'filter' => 'sn=*', // Active Directory Filter... Change as needed
'search_fields' => array('Email' => 'mail', 'Name' => 'cn'), // search fields
'name_field' => 'cn', // this field represents the contact's name
'email_field' => 'mail', // this field represents the contact's e-mail
'scope' => 'sub', // search mode: sub|base|list
'fuzzy_search' => 0); // server allows wildcard search
$rcmail_config['dont_override'] = array(timezone, dst_active, language); // no user override
$rcmail_config['timezone'] = -6; // your time zone
$rcmail_config['prefer_html'] = FALSE; // no html
$rcmail_config['htmleditor'] = FALSE; // no html
$rcmail_config['preview_pane'] = TRUE; // Preview pane :)
Notes: We have Outlook users so I replicated the folders used.
Fields for version, user_id, and pwd were added to the ldap area for Active Directory
-
Point your browser to http://192.168.1.253/mail
Enter username and password for the Restricted Areas! box. (these are from htpasswd.txt setup)
You should have a RoundCube logon page. Below are some errors I encountered.
Note: D:\www\utils\mail\config\main.inc.php has a setting $rcmail_config[‘debug_level’] = 1’
You can change this to 4 to show on screen errors. Helps if you don’t have error log working correctly.
Error 1f4
My problem was a database error. // these are corrected in the mysql5.initial.zip available in the MySQL Post.
Some possible causes:
No database/databaseuser for roundcube // consult MySQL Post above.
Incorrect permissions for roundcubeuser on the roundcube database // consult MySQL Post above.
Incorrect mysql driver in D:\www\utils\mail\config\db.inc.php // needs mysqli as noted in MySQL Post
Incorrect info for roundcubeuser and or roundcube database in D:\www\utils\mail\config\db.inc.php // consult MySQL Post above.
Incorrect database values // NOT NULL vrs NULL again…these are corrected in the mysql5.initial.zip available in the MySQL Post.
Logon Errors
Config hMailServer to log activity then check those logs.
Check RoundCube errors log D:\www\logs\roundcube\errors
PHP Errors
Logging Errors
Incorrect setting in D:\www\utils\mail\config\main.inc.php
Errors:
$rcmail_config['temp_dir'] = 'D:/www/logs/roundcube/temp/';
$rcmail_config['log_dir'] = 'D:/www/logs/roundcube/';
Note: these need to be FORWARD SLASH (IE: / not \)
Log Errors
RoundCube errors log to D:\www\logs\roundcube\errors on this tutorial.
PHP Warning: Cannot modify header information - headers already sent in ...etc
Don't have a fix at this time. I get this Warning ever time an email is sent. No apparent effect.
Attachments hiden/not showing in Internet Explorer
Internet Explorer has problems with float. For a lack of better knowledge I commented it out.
Open D:\www\utils\mail\skins\default\mail.css
#attachment-list li
{
/* Change 01/01/07*/
/* float: left;*/
height: 18px;
font-size: 11px;
padding: 2px 10px 0px 10px;
}
Corrupt email attachments
With the default $rcmail_config['smtp_server'] = ''; setting my mail/attachments were courrupt. PHP mailing problem?
Open D:\www\utils\mail\config\main.inc.php
// Change 01/01/07
//$rcmail_config['smtp_server'] = '';
$rcmail_config['smtp_server'] = 'localhost';
-
Downloadjxplorer http://www.jxplorer.org/
Note: jxplorer installed and worked correctly on one machine, but installed and failed to open with the icon on another machine. Had to use the jxplorer .bat file to open it. C:\Program Files\JXplorerjxplorer.bat
This can be used to explore Active Directory on “PDCâ€ÂÂ
Setup for opening a connection to ‘PDC†as follows
Host: 192.168.1.254
Protocal: LDAP v3
DSML Service: (leave alone)
Base DN: DC=southtown,DC=k12,DC=mo,DC=us
Level: Choose User + Password
User DN: ImUrHuckleBerry
Password: SuperCrypticPassword
Active Directory variables were setup in D:\www\utils\mail\config\main.inc.php in The Config Files Post.
Need to mod rcube_ldap.inc
Open D:\www\utils\mail\program\include\rcube_ldap.inc Search for and Change
// Change 01/01/07
// Change this for filtering options.
//$this->filter = "(cn=*)";
$this->filter = ($this->prop['filter']);";
Same file D:\www\utils\mail\program\include\rcube_ldap.inc Search for and Change
/**
* Establish a connection to the LDAP server
*/
function connect()
{
if (!function_exists('ldap_connect'))
raise_error(array('type' => 'ldap', 'message' => "No ldap support in this installation of PHP"), true);
if (is_resource($this->conn))
return true;
if (!is_array($this->prop['hosts']))
$this->prop['hosts'] = array($this->prop['hosts']);
foreach ($this->prop['hosts'] as $host)
{
if ($lc = @ldap_connect($host, $this->prop['port']))
{
ldap_set_option($lc, LDAP_OPT_PROTOCOL_VERSION, $this->prop['version']);
$this->prop['host'] = $host;
$this->conn = $lc;
// Change 05/10/07
$this->_bind();
break;
}
}
-
<?php
//this is the main code
$USER_ID = "ImUrHuckleBerry";
$PWD = "SuperCrypticPassword";
//$dn = "OU=Staff,OU=Accounts,OU=Elementry School,OU=Southtown School District,DC=southtown,DC=k12,DC=mo,DC=us";
$dn = "OU=Southtown School District,DC=southtown,DC=k12,DC=mo,DC=us";
$ad = ldap_connect("192.168.1.254", "389")
or die("Couldn't connect to AD!");
ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
//ldap_set_option($ad, LDAP_OPT_REFERRALS, 0);
$bd = ldap_bind($ad,$USER_ID,$PWD)
or die("Couldn't bind to AD!");
$filter = "(sn=*)"; //cn=*, mail=*, givenname=*, sn=*
$result = ldap_search($ad, $dn,$filter);
$entries = ldap_get_entries($ad, $result);
for ($i=0; $i<$entries["count"]; $i++)
{
echo $entries[$i]["displayname"][0]." ";
echo $entries[$i]["mail"][0]."<br />";
}
ldap_unbind($ad);
?>
Note: Criteria for "ThIs NaMe" in ($entries[$i]["ThIs NaMe"]) needs to be in lower case (IE: telephonenumber not telephoneNumber)
-
Tips
phpMyAdmin is your friend.
hMailServer is Sweeeeet // like concentrated honey
Smile... it no crack face.
Tricks
organization and reply_to
Upon Creation of user in the roundcube database I wanted their fields in identities for organization and reply_to automatically generated.
Notes: Had to fix my Wishs reply-to (listed below) first.
Fix as follows.
Work in progress.
No new Identities for my users
I don’t want my users to be able to make new Identities. Location: Menu Personal Setting Tab Identities
This is a brutal hack. Was not exactly what I was looking for but its what I've settled with… for the time being.
Hope someone has a better solution.
Fix as follows.
Work in progress.
Active Directory Address Book Showing Accounts that I don't want.
Acounts like postmaster, webmaster and Lunch are in my Address Book from Active Directory.
I'm sure there is a better way to do this; but here is my fix. /hand behind ear listening for a reply
Fix as follows.
Work in progress.
Wishes
reply-to
I wish the database did not use reply-to. I have fixed this by renaming it to reply_to in the database and mail files that use it.
This is related to a bug in MySQL with Hyphens (IE:"-").
Fix as follows.
Work in progress.
-
I’m a very poor speller. I run everything through word but that doesn’t catch it all. If you catch any errors please let me know and I will fix them. ;)
I don’t claim to be a programmer. If you see a better way to do what I have done please post it and I will change my tutorial. Thanks in advance for any suggestions.
This tutorial was composed while viewing through Intenet Explorer 6 at 1280 by 1024. If the format is jacked, its more then likely Microsofts fault :)
Note: Code was used from many places. Would like to thank the original authors but my memory fails.