When installing, and you find yourself with a consistent:
Mimetype to file extension mapping: NOT OKthe problem may, of course, be related to the fact that PHP can't get at the file. If that seems unlikely (you are, after all, a competent server admin), the problem could also be the file's contents. The problem may be a problem with the RoundCube code.
Here is what is happening:
In the file
/installer/test.php, a call is made to
RCI->check_mime_extensions().
RCI->check_mime_extensions() sends a selection of common mime types to
rcube_mime::get_mime_extensions(). The selections are:
application/zip zip
application/x-tar tar
application/java-archive jar
image/gif gif
image/svg+xml svg
rcube_mime::get_mime_extensions() accepts either a mime-type or defaults to null. This function begins by building an array of filepaths to look for the file containing the mime-types. It checks
$config['mime_type'] and if not empty, loads that into the array of paths to check.
This is not just a path to the file, this is the complete path of the file, '
C:/Hiawatha/conf/mimetypes.conf', for example. It also adds to the array a list of common paths of this file for the operating system being used.
So, if
rcube_mime::get_mime_extensions('image/gif') does not return 'gif', then there is a problem. But the message "
Please set a valid path to your webserver's mime.types file to the mime_types config option." is ridiculously misleading. There is a problem with the contents of the file.
In my case, there are two problems: (1)the wrong mime-type for 'jar' as listed in the
mimetypes.conf file, and (2)
RCI->check_mime_extensions() not making the proper check on the result from
rcube_mime::get_mime_extensions().
(The mime-types file I am using is supplied by the Hiawatha webserver (up to v9.6).)
(1) The file has:
application/x-java-archive jar
while
RCI->check_mime_extensions() is checking:
application/java-archive jar
(2)
rcube_mime::get_mime_extensions() scans the file and loads up two arrays. They are:
$mime_types['application/x-tar'] = array('tgz', 'tar')
$mime_extensions = array('tgz' => 'application/x-tar', 'tar' => 'application/x-tar')
(This function also loads in a few less-well-known mime-types in case they are missing from the file.)
So,
rcube_mime::get_mime_extensions('application/x-tar') will return
array('tgz', 'tar') to
RCI->check_mime_extensions() as
$ext. Here is the problem:
if ($ext[0] != $expected)if ('tgz' != 'tar')RCI->check_mime_extensions() is collecting the errors into an array and returning that array to the
test.php code, but the
test.php code is simply checking for a non-empty array - not showing the contents of the array. So,
you really don't know why it's NOT OK.
The fix:
if (!in_array(strtolower($expected),strtolower($ext)))If the RoundCube Mailer install code is expecting the file extensions to be in a priority order ('tar' then 'tgz'), then the
mimetypes.conf file got that wrong. If there is no priority order in a properly formatted mime-types file, then the installer code got it wrong.
Other posts that were searched and did not provide a satisfactory answer:
http://www.roundcubeforum.net/index.php/topic,16841.msg54634.html#msg54634http://www.roundcubeforum.net/index.php/topic,19265.msg55252.html#msg55252http://www.roundcubeforum.net/index.php/topic,15450.msg54178.html#msg54178http://www.roundcubeforum.net/index.php/topic,16899.msg52586.html#msg52586