Roundcube Community Forum

News and Announcements => General Discussion => Topic started by: JabbaTek on November 06, 2008, 04:33:23 PM

Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: JabbaTek on November 06, 2008, 04:33:23 PM
For all of those who have been having issues with MSSQL and RoundCube, I give to you the answer.

I have RoundCube (with HMail) running in the following environment.  It works great and is fast.

Windows Server 2008 Standard
IIS 7
PHP 5.x.x
Beta version on RoundCube (latest version)
Miscrosft SQL Server 2005

First you will need to have installed MSSQL.  Most will be running MSDE 2000 or SQL Express 2005.  Both are the free versions from Microsoft.

Second, create a database such as RoundCube.  IF you have SQL Express 2005, then you will need to download (if you haven't already) SQL Management Studio Express.  

Third, open the mssql.initial file found in the \SQL folder where RoundCube Mail is installed.  Copy the contents of that file into a new query window in Management Studio.  Make sure you selected your new database before opening a new query window to set the contect to that database.  Execute the statements that you just copied in.

Fourth, you will need to edit the db.inc.php file in the Config folder.  Find the line that starts with $rcmail_config['db_dsnw'].  I will provide 2 examples of how to write the line.  The examples assume the following:

Machine name (of host) = MAILSERVER
Database name = RoundCube
Username = rcmail
Password = webmail

Example 1:
'mssql://rcmail:webmail@MAILSERVER/RoundCube'

Example 2 (assumes you have an instance of MSSQL called SQLEXPRESS):
'mssql://rcmail:webmail@MAILSERVER\\SQLEXPRESS/RoundCube'

if you installed SQL Express 2005, you will most likely have the instance.

Last but not least, there is a missing function in the \program\lib\MDB2\Driver\mssql.php file.  The function is SetCharSet.  If you do not add the missing function, you will receive an error message stating that the SetCharSet method is not implemented.  I have attached a copy of my mssql.php file for convenience, but here are the missing lines in that file.

    function setCharset($charset, $connection = null)
    {
       
      return true;

    }

Once this is all done, it should work just fine (at least the database portion).

If you have questions or run into trouble getting it to work please reply and I will be happy to try and help.
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: Rilla on November 06, 2008, 05:50:18 PM
JABBATEK YOU ARE AN 0:) !!!  I LOVE YOU!!!

I was having issues with my server and your solution above works perfectly :D

I have been searching everywhere for this solution and you solved it!!

THANK YOU!

-Rilla
Title: Read/Write permissions to the database
Post by: JabbaTek on November 06, 2008, 06:17:21 PM
In addition to all that I have explained, you will need to make sure that the username you plan to use to connect to the RoundCube Mail database has read/write permissions to that database.
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: Rilla on November 06, 2008, 09:17:49 PM
I got these settings to work by using the default config files.  I copied the config files into a backup file and edited the deafult config files.  I did not use the roundcube configurator.

JabbaTek - How did you manage the config files for your server?

-Rob
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: JabbaTek on November 07, 2008, 11:08:13 AM
The "configurator" or the web page admin interface does not provide an option for MSSQL.  So it does not know how to configure it.  I did the same as you, I had to manually edit the db.inc.php file.  

If figured out the how to format the string by looking at the parseDSN function.

I got the db connection to work, then I got the method not implemented error.  I figured out that the mssql.php, along with the others like mysql.php, override a base class of mdb2.php.  That's where I discovered that the setCharSet function was missing from the mssql.php file.  SQL server doesn't support the commands it was trying to perform so I removed the code and had the function just return true.  It worked and the error went away.
Title: Update to guide for MSSQL
Post by: JabbaTek on November 07, 2008, 05:50:31 PM
If you get an error stating that Inerting a null value caused a constraint violation, you will need to open the affected table, usually the Users table and set the columns to allow null.  If you need help with this on MSSQL, please let me know.

If you do not want to ask questions in the thread, you can send me a private message.
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: JabbaTek on November 10, 2008, 04:46:53 PM
It also appears that the scripts to create the tables for RC Mail in an MSSQL database have an error.  The piece that creates the Identities table leaves off a column. It does not add the "html_signature" column (w/o quotes).  You will need to add this column manually to your Identities table so you can create an identity so you can send messages.

Below is the information for creating the column in the IDentities table.

Name: html_signature
Data Type: bit
Allow Null: False or No
Default Value: 0
Title: Sqlexpress
Post by: JabbaTek on November 14, 2008, 12:44:41 AM
It turns out that RC Mail will not work with an instance of mssql other than the default machine name.  So let's say your server name is MAILSERVER.  With SQL 2005 and up, if you install the express (free) versions, they create an instance called SLEXPRESS automatically.  This means that the host (server) that you would refer to is actually MAILSERVER\SQLEXPRESS.  

The parseDsn function is not setup to handle this scenario.  I will be working on fixing the parseDsn function and submitting it for download and for inclusion (hopefully) in future releases.  

I will post the fix along with a complete guide to setting up with mssql, once I have the function fixed.  The guide will include all of the kinks previously mentioned.
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: Bonx on November 25, 2008, 07:07:21 AM
Hmmm..

First some details:

Windows SRV 2008
IIS 7
PHP 5.2.6
hMail
Roundcube 0.2 Beta (latest DL)
SQL Server 2005 std. (installed with instancename 'SQLSERVER')
Database is uprunning (can login via webinterface and see the full DB with full tables as in mssql.initial)
I have defined the user as DBO

Connection string:
$rcmail_config = 'mssql://rcwebmail:webmail@localhost\\SQLServer/RoundCube';

Tried with and without a defined DSN - gave me same result

The result is, that roundcube cant connect to the database.

Can some tell me whats missing or what i'm doing wrong ?

/ Bronx
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: JabbaTek on November 26, 2008, 05:53:31 PM
MSSQL Server does not use "localhost" as an identifier.  You have to use either "(Local)" with the parenthesis but not the quotes, or you need to use the machine name in place of localhost.  If your machine name is SERVER then either of the following examples should work.

'mssql://rcwebmail:webmail@(Local)\\SQLServer/RoundCube';

'mssql://rcwebmail:webmail@SERVER\\SQLServer/RoundCube';

If neither of the above examples work, let me know.  There may be an issue with using named instances with RC Mail which I may have figured out how to fix.  

Also, make sure that mssql appears in the list of extensions when you run phpinfo().
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: Bonx on November 27, 2008, 02:18:02 AM
I haved tried a lot.

- MSSQL is enabled in PHP, see below:
mssql
MSSQL Support enabled
Active Persistent Links  0  
Active Links  0  
Library version  7.0

- I have tried several things in the connection string
    - Localhost
    - IP Address
    - Machine name

Just tried with (local), still the same result.

Is it possible to connect via TCP/IP instead ?

let me know if I have to try anything else :)

/ Bonx
Title: SQL Server 2008
Post by: lee.rekab@gmail.com on December 10, 2008, 05:45:20 AM
Hi,

I am trying to get Roundcube to work with SQL Server 2008. Is this currently supported, or planned to be soon?

Lee
Title: Error Msg 102, Level 15, State 1, Line 6
Post by: vhtnyc on March 07, 2009, 03:19:35 AM
Hi there,

I tried to run the query mssql_initial.sql on SQL2008Express and got this error.

I followed all your steps but no luck.
When I went to the website, it just gave me blank screen
Hmail is running fine.

O/S: Windows Server 2003 Std R2
SQL2008Express

mssql://roundcube:mypass@hmailserver\sqlexpress/roundcube
or
mssql://roundcube:mypass@hmailserver\\sqlexpress/roundcube
or
mssql://sa:sa_pass@hmailserver\sqlexpress/roundcube

Please help !

Thank you.
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: vhtnyc on March 07, 2009, 11:15:12 PM
I forgot to attach the error when I ran the mssql.initial.sql query on SQL2008Express

Msg 102, Level 15, State 1, Line 6
Incorrect syntax near ','.

Hope somebody can point me the right direction.

Thanks.
Title: So close
Post by: fatlip on March 15, 2009, 02:02:39 PM
I have followed these instructions and I know I am really close to having this working!!

I am running 2K3 Enterprise with IIS6.
PHP 5.2.9-1 using fastcgi, mssql enabled in the config files
MSSQL Express 2005
Roundcube 0.2.1

I created the database 'roundcube' in SQL Express, opened and ran the 'mssql.initial.sql' file. It generated the following error, although it looks like it created all the tables.

Code: [Select]
Msg 102, Level 15, State 1, Line 6
Incorrect syntax near ','.


I created a user rcmail with a password of rcwebmail. Edited the db.inc.php to look like this:
Code: [Select]
$rcmail_config['db_dsnw'] = 'mssql://rcmail:rcwebmail@HMAIL\\SQLEXPRESS/roundcube';

I placed the extra code in the mssql.php file as shown below:

class MDB2_Driver_mssql extends MDB2_Driver_Common
{
    // {{{ properties

    var $string_quoting = array('start' => "'", 'end' => "'", 'escape' => "'", 'escape_pattern' => false);

    var $identifier_quoting = array('start' => '[', 'end' => ']', 'escape' => ']');

function setCharset($charset, $connection = null)
{

return true;

}

    // }}}
    // {{{ constructor


I enable trace debugging and when I attempt to load the webmail page, this is what I get.

Code: [Select]
MDB2 Error: connect failed (-24): _doConnect: [Error message: unable to establish a connection]


Any ideas?
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: funklet on August 02, 2009, 01:55:33 PM
Hi,

If there's anyone out there still trying to get this working... like me...

In addition to the following:

1) Do NOT install the Microsoft PHP SQL Driver SQLSrv, make sure there are no references to it anywhere!
2) Ensure you have the extension=php_mssql.dll in php.ini
3) Verify that mssql is working properly by using the phpinfo() function in a php file in your mail root
4) Ensure you put the setCharSet blank function in the right place.
5) You will need to add the html_signature field and change some of the fields to allow NULLs.

I think all of the above is detailed in this post somewhere, or only a google away...

If you have the problem with SERVER\SQLEXPRESS then use the Sql Server Configuration Manager to set an Alias for the server e.g. SERVER01

This will mean instead of:

mssql://user:pass@SERVER\\SQLEXPRESS/roundcube
(which I could not get to work)

You can use:

mssql://user:pass@SERVER01/roundcube
(which is now working)

..If only I could get the plugins working properly...
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: Joel on August 08, 2009, 03:07:12 PM
Quote from: JabbaTek;15099
For all of those who have been having issues with MSSQL and RoundCube, I give to you the answer.

I have RoundCube (with HMail) running in the following environment.  It works great and is fast.

Windows Server 2008 Standard
IIS 7
PHP 5.x.x
Beta version on RoundCube (latest version)
Miscrosft SQL Server 2005

First you will need to have installed MSSQL.  Most will be running MSDE 2000 or SQL Express 2005.  Both are the free versions from Microsoft.

Second, create a database such as RoundCube.  IF you have SQL Express 2005, then you will need to download (if you haven't already) SQL Management Studio Express.  

Third, open the mssql.initial file found in the \SQL folder where RoundCube Mail is installed.  Copy the contents of that file into a new query window in Management Studio.  Make sure you selected your new database before opening a new query window to set the contect to that database.  Execute the statements that you just copied in.

Fourth, you will need to edit the db.inc.php file in the Config folder.  Find the line that starts with $rcmail_config['db_dsnw'].  I will provide 2 examples of how to write the line.  The examples assume the following:

Machine name (of host) = MAILSERVER
Database name = RoundCube
Username = rcmail
Password = webmail

Example 1:
'mssql://rcmail:webmail@MAILSERVER/RoundCube'

Example 2 (assumes you have an instance of MSSQL called SQLEXPRESS):
'mssql://rcmail:webmail@MAILSERVER\\SQLEXPRESS/RoundCube'

if you installed SQL Express 2005, you will most likely have the instance.

Last but not least, there is a missing function in the \program\lib\MDB2\Driver\mssql.php file.  The function is SetCharSet.  If you do not add the missing function, you will receive an error message stating that the SetCharSet method is not implemented.  I have attached a copy of my mssql.php file for convenience, but here are the missing lines in that file.

    function setCharset($charset, $connection = null)
    {
       
      return true;

    }

Once this is all done, it should work just fine (at least the database portion).

If you have questions or run into trouble getting it to work please reply and I will be happy to try and help.
By any chance do you know how to set up the "outgoing server" on a Palm Pre so that I can reply to my company e-mail.  I have been able to get my mail pushed to the Palm, but I do not know the server that Round Cube uses so that I can reply directly to those e-mails.  Any help is greatly appreciated.

Joel
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: Jass on August 10, 2009, 08:08:21 AM
Hey Guys,

I installed and configured RoundCube as you wrote and it's possible to open the login-page.
My problem now is that I cannot login with my email-adresses, set up in hmailserver. I tried the internal and the external adresses but I allways get a message that the login failed.
Any idea how to log in?

Ok, got it myself.
Autocreate was set to TRUE but the mssql.initial.sql script sets the table users to NULL for most of the fields. Changed this values and now it works.
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: cmillens on October 11, 2009, 12:06:40 AM
wel I've managed to get the login screen following these directions. What a PAIN PHP is on IIS 6.0

Some notes on what I've discovered.

DO NOT use the thread safe php implementation. It only makes you go bald. Appears to work but fast requests will shut down FastCGI in a heartbeat.

Now to my problem ...

The login page comes up and then, after entering credentials I get this noise:

The page cannot be displayed
You have attempted to execute a CGI, ISAPI, or other executable program from a directory that does not allow programs to be executed.
--------------------------------------------------------------------------------

Please try the following:

•Contact the Web site administrator if you believe this directory should allow execute access.
HTTP Error 403.1 - Forbidden: Execute access is denied.
Internet Information Services (IIS)

SAY WHAT? Why would the login page work but subsequent pages NOT work?

Anyone else seen this?

Installation details:
Windows Server 2003 Enterprise Build 3790
FastCGI 6.1.36.1
PHP 5.2.11
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: SKaero on October 11, 2009, 05:11:22 AM
Have you checked the folder privileges?
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: paulinabalk on October 11, 2009, 08:14:28 AM
Quote from: skaero;22038
Have you checked the folder privileges?


Whoa!

Am able to set up my RoundCube Mail and MSSQL Server  Reply to Thread.

Actually, folder privileges was the issue.

Thanks again.
Title: Folder priv's
Post by: cmillens on October 11, 2009, 11:07:51 AM
Yes I have. Both in IIS's snap-in and on the drive. NETWORK SERVICE has full control on the folder in the file system and the folder in the IIS snap-in is set to Scripts and Executables. :(

What I don't understand is why the login page comes up just fine but I get that nonsense as soon as I try to login!
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: SKaero on October 11, 2009, 12:49:09 PM
Is there anything in your error log?
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: cmillens on October 11, 2009, 05:56:53 PM
IIS Logs show the request for /index.php.
PHP Logs are empty
Windows Event Log shows nothing from IIS.
Roundcube logs are empty.

I'm completely STUMPED.

I can run phpBB on this server but not RoundCube :(
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: cmillens on October 13, 2009, 11:14:37 PM
Well, I was sure hoping that someone here could help. Looks like I'm going to have to find some other alternative.
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: SKaero on October 14, 2009, 05:53:40 AM
I don't know IIS very well so I can't be to much help, but I was wondering if it could be a .htaccess problem. You could try removing it and see if it helps.
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: MKNDK on November 05, 2011, 03:41:36 PM
Last but not least, there is a missing function in the \program\lib\MDB2\Driver\mssql.php file. The function is SetCharSet. If you do not add the missing function, you will receive an error message stating that the SetCharSet method is not implemented. I have attached a copy of my mssql.php file for convenience, but here are the missing lines in that file.
 
function setCharset($charset, $connection = null)
 {

 return true;
 
}
 


could you please advice where i can find the mssql.php file as you mentioned that you have attached.

Thank you
Title: Here is the answer for setting up RoundCube Mail and MSSQL Server
Post by: MKNDK on November 06, 2011, 02:03:28 AM
i tried al the above still

Check DB config
 DSN (write):  NOT OK(MDB2 Error: not found)

Please help!