Loading

Web-интерфейс RoundCube для вашего почтового сервера

24.10.2010 - 21:01

Необходимо было прикрутить web-интерфейс для Mail-сервера, что бы удаленные пользователи могли работать с своей корпоративной почтой. Перепробовав много web-клиентов, пришел к выводу, что российская разработка RoundCube имеет более дружественный интерфейс и функциональность.
Обновляем порты и начинам устанвку:

[root@srv /]# cd /usr/ports/mail/roundcube
[root@srv /usr/ports/mail/roundcube]#make config

В открывшемся окне выбираем:
[X] MYSQL     Use MySQL backend
[X] SSL         Enable SSL support (imaps or google spellcheck)
[X] LOCALCHECK  Install internal spellchecker
[X] AUTOCOMP  Enable autocomplete in login form
[root@srv /usr/ports/mail/roundcube]#make install clean

После установки инсталятор просит нас создать БД и пользователя, импортировать в нее дамп мускула, отредактировать конфиг под свои реалии и выставить пермишенсы на db.inc.php в 660.

. Create a new database and a database user for RoundCube
. Create database tables using the queries in file
'SQL/*.initial.sql'
. Modify the files in config/* to suit your local environment
. Don't forget to set db.inc.php mode to 660.

Сказали, значит нужно делать, немного почитав INSTALL (/usr/local/share/doc/roundcube/INSTALL), приступаем к созданию БД и юзера:

[root@srv /usr/local/share/doc/roundcube]# mysql -u root -p
Enter password:
mysql> CREATE DATABASE roundcubemail /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
Query OK, 1 row affected (0.02 sec)
mysql> GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcube@localhost  IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye

Импортируем в БД дамп mysql.initial.sql:
[root@srv /]#cd /usr/local/www/roundcube
[root@srv /usr/local/www/roundcube]#mysql -u root -p roundcubemail < SQL/mysql.initial.sql
Enter password:
[root@srv /usr/local/www/roundcube]#

Далее правим конфиг подключения roundcube к БД:
[root@srv /]#ee /usr/local/www/roundcube/config/db.inc.php
<?php
$rcmail_config = array();
# Тут говорим использовать MySQL, указываем логи,пароль для БД "roundcubemail"
$rcmail_config['db_dsnw'] = 'mysql://roundcubemail:qwerty@localhost/roundcubemail';
$rcmail_config['db_dsnr'] = '';
$rcmail_config['db_max_length'] = 512000;  // 500K
$rcmail_config['db_persistent'] = FALSE;
$rcmail_config['db_table_users'] = 'users';
$rcmail_config['db_table_identities'] = 'identities';
$rcmail_config['db_table_contacts'] = 'contacts';
$rcmail_config['db_table_session'] = 'session';
$rcmail_config['db_table_cache'] = 'cache';
$rcmail_config['db_table_messages'] = 'messages';
$rcmail_config['db_sequence_users'] = 'user_ids';
$rcmail_config['db_sequence_identities'] = 'identity_ids';
$rcmail_config['db_sequence_contacts'] = 'contact_ids';
$rcmail_config['db_sequence_cache'] = 'cache_ids';
$rcmail_config['db_sequence_messages'] = 'message_ids';
?>

Правим конфиг самого roundcube:
[root@srv /]# ee /usr/local/www/roundcube/config/main.inc.php
<?php
$rcmail_config = array();

// system error reporting: 1 = log; 2 = report (not implemented yet), 4 = show, 8 = trace
$rcmail_config['debug_level'] = 1;

// log driver:  'syslog' or 'file'.
$rcmail_config['log_driver'] = 'file';

// Syslog ident string to use, if using the 'syslog' log driver.
$rcmail_config['syslog_id'] = 'roundcube';

// Syslog facility to use, if using the 'syslog' log driver.
// For possible values see installer or http://php.net/manual/en/function.openlog.php
$rcmail_config['syslog_facility'] = LOG_USER;

// use this folder to store log files (must be writeable for apache user)
// This is used by the 'file' log driver.
$rcmail_config['log_dir'] = 'logs/';

// use this folder to store temp files (must be writeable for apache user)
$rcmail_config['temp_dir'] = 'temp/';

// enable caching of messages and mailbox data in the local database.
// this is recommended if the IMAP server does not run on the same machine
$rcmail_config['enable_caching'] = TRUE;

// lifetime of message cache
// possible units: s, m, h, d, w
$rcmail_config['message_cache_lifetime'] = '10d';

// automatically create a new RoundCube user when log-in the first time.
// a new user will be created once the IMAP login succeeds.
// set to false if only registered users can use this service
$rcmail_config['auto_create_user'] = TRUE;

// the mail host chosen to perform the log-in
// leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// To use SSL connection, enter ssl://hostname:993
$rcmail_config['default_host'] = 'localhost';

// TCP port used for IMAP connections
$rcmail_config['default_port'] = 143;

// IMAP auth type. Can be "auth" (CRAM-MD5), "plain" (PLAIN) or "check" to auto detect.
// Optional, defaults to "check"
$rcmail_config['imap_auth_type'] = null;

// If you know your imap's root directory and its folder delimiter,
// you can specify them here. Otherwise they will be determined automatically.
$rcmail_config['imap_root'] = null;
$rcmail_config['imap_delimiter'] = null;

// Automatically add this domain to user names for login
// Only for IMAP servers that require full e-mail addresses for login
// Specify an array with 'host' => 'domain' values to support multiple hosts
$rcmail_config['username_domain'] = '';

//Тут указываем свой почтовый домен
$rcmail_config['mail_domain'] = 'mail.example.com';

// Path to a virtuser table file to resolve user names and e-mail addresses
$rcmail_config['virtuser_file'] = '';

// Query to resolve user names and e-mail addresses from the database
// %u will be replaced with the current username for login.
// The query should select the user's e-mail address as first col
$rcmail_config['virtuser_query'] = '';

// use this host for sending mails.
// to use SSL connection, set <a href="//smtp.host.com<br />
//" title="//smtp.host.com<br />
//">ssl://smtp.host.com<br />
//</a> if left blank, the PHP mail() function is used
//SMTP-сервер у нас на том же хосте где и раундкуб
$rcmail_config['smtp_server'] = 'localhost';

// SMTP port (default is 25; 465 for SSL)
$rcmail_config['smtp_port'] = 25;

// SMTP username (if required) if you use %u as the username RoundCube
// will use the current username for login
$rcmail_config['smtp_user'] = '%u';

// SMTP password (if required) if you use %p as the password RoundCube
// will use the current user's password for login
$rcmail_config['smtp_pass'] = '%p';

// SMTP AUTH type (DIGEST-MD5, CRAM-MD5, LOGIN, PLAIN or empty to use
// best server supported one)
$rcmail_config['smtp_auth_type'] = 'PLAIN';

// SMTP HELO host
// Hostname to give to the remote server for SMTP 'HELO' or 'EHLO' messages
// Leave this blank and you will get the server variable 'server_name' or
// localhost if that isn't defined.
$rcmail_config['smtp_helo_host'] = 'mail.example.com';

// Log sent messages
$rcmail_config['smtp_log'] = TRUE;

// How many seconds must pass between emails sent by a user
$rcmail_config['sendmail_delay'] = 0;

// These cols are shown in the message list. Available cols are:
// subject, from, to, cc, replyto, date, size, flag, attachment
$rcmail_config['list_cols'] = array('subject', 'from', 'date', 'size', 'flag', 'attachment');

// Includes should be interpreted as PHP files
$rcmail_config['skin_include_php'] = FALSE;

// Session lifetime in minutes
// must be greater than 'keep_alive'/60
$rcmail_config['session_lifetime'] = 10;

// check client IP in session athorization
$rcmail_config['ip_check'] = false;

// Use an additional frequently changing cookie to athenticate user sessions.
// There have been problems reported with this feature.
$rcmail_config['double_auth'] = false;

// this key is used to encrypt the users imap password which is stored
// in the session record (and the client cookie if remember password is enabled).
// please provide a string of exactly 24 chars.
$rcmail_config['des_key'] = 'rcmail-!24ByteDESkey*Str';

// the default locale setting (leave empty for auto-detection)
// RFC1766 formatted language name like en_US, de_DE, de_CH, fr_FR, pt_BR
$rcmail_config['language'] = null;

// use this format for short date display
$rcmail_config['date_short'] = 'D H:i';

// use this format for detailed date/time formatting
$rcmail_config['date_long'] = 'd.m.Y H:i';

// use this format for today's date display
$rcmail_config['date_today'] = 'H:i';

// add this user-agent to message headers when sending
$rcmail_config['useragent'] = 'RoundCube Webmail/0.2.1';

//Использовать это имя для заголовков страниц
$rcmail_config['product_name'] = 'mail.example.com';

// store draft message is this mailbox
// leave blank if draft messages should not be stored
$rcmail_config['drafts_mbox'] = 'Drafts';

// store spam messages in this mailbox
$rcmail_config['junk_mbox'] = 'Junk';

// store sent message is this mailbox
// leave blank if sent messages should not be stored
$rcmail_config['sent_mbox'] = 'Sent';

// move messages to this folder when deleting them
// leave blank if they should be deleted directly
$rcmail_config['trash_mbox'] = 'Trash';

// display these folders separately in the mailbox list.
// these folders will also be displayed with localized names
$rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent', 'Junk', 'Trash');

// automatically create the above listed default folders on login!!!!!!!
$rcmail_config['create_default_folders'] = TRUE;

// protect the default folders from renames, deletes, and subscription changes
$rcmail_config['protect_default_folders'] = TRUE;

// if in your system 0 quota means no limit set this option to TRUE
$rcmail_config['quota_zero_as_unlimited'] = FALSE;

// Behavior if a received message requests a message delivery notification (read receipt)
// 0 = ask the user, 1 = send automatically, 2 = ignore (never send or ask)
$rcmail_config['mdn_requests'] = 0;

// Use this charset as fallback for message decoding
$rcmail_config['default_charset'] = 'UTF-8';

// Make use of the built-in spell checker. It is based on GoogieSpell.
// Since Google only accepts connections over https your PHP installatation
// requires to be compiled with Open SSL support
$rcmail_config['enable_spellcheck'] = TRUE;

// Set the spell checking engine. 'googie' is the default. 'pspell' is also available,
// but requires the Pspell extensions. When using Nox Spell Server, also set 'googie' here.
$rcmail_config['spellcheck_engine'] = 'googie';

// For a locally installed spellcheker, specify the URI to call it, for example:
// 'http://' . $_SERVER['HTTP_HOST'] . '/spellchecker.php?lang='
// Leave empty to use the Google spell checking service, what means
// that the message content will be sent to Google in order to check spelling
$rcmail_config['spellcheck_uri'] = '';

// These languages can be selected for spell checking.
// Configure as a PHP style hash array: array('en'=>'English', 'de'=>'Deutsch');
// Leave empty for default set of Google spell check languages, should be defined
// when using local Pspell extension
$rcmail_config['spellcheck_languages'] = NULL;

// path to a text file which will be added to each sent message
// paths are relative to the RoundCube root folder
$rcmail_config['generic_message_footer'] = '';

// add a received header to outgoing mails containing the creators IP and hostname
$rcmail_config['http_received_header'] = false;

// this string is used as a delimiter for message headers when sending
// leave empty for auto-detection
$rcmail_config['mail_header_delimiter'] = NULL;

// session domain: .example.org
$rcmail_config['session_domain'] = '';

// This indicates which type of address book to use. Possible choises:
// 'sql' (default) and 'ldap'.
// If set to 'ldap' then it will look at using the first writable LDAP
// address book as the primary address book and it will not display the
// SQL address book in the 'Address Book' view.
$rcmail_config['address_book_type'] = 'sql';

// In order to enable public ldap search, configure an array like the Verisign
// example further below. if you would like to test, simply uncomment the example.
$rcmail_config['ldap_public'] = array();

// An ordered array of the ids of the addressbooks that should be searched
// when populating address autocomplete fields server-side. ex: array('sql','Verisign');
$rcmail_config['autocomplete_addressbooks'] = array('sql');

// don't allow these settings to be overriden by the user
$rcmail_config['dont_override'] = array();

// Set identities access level:
// 0 - many identities with possibility to edit all params
// 1 - many identities with possibility to edit all params but not email address
// 2 - one identity with possibility to edit all params
// 3 - one identity with possibility to edit all params but not email address
$rcmail_config['identities_level'] = 0;

// try to load host-specific configuration
// see <a href="http://trac.roundcube.net/wiki/Howto_Config" title="http://trac.roundcube.net/wiki/Howto_Config">http://trac.roundcube.net/wiki/Howto_Config</a> for more details
$rcmail_config['include_host_config'] = false;

// don't let users set pagesize to more than this value if set
$rcmail_config['max_pagesize'] = 200;

// mime magic database
$rcmail_config['mime_magic'] = '/usr/share/misc/magic';

// default sort col
$rcmail_config['message_sort_col'] = 'date';

// default sort order
$rcmail_config['message_sort_order'] = 'DESC';

// THIS OPTION WILL ALLOW THE INSTALLER TO RUN AND CAN EXPOSE SENSITIVE CONFIG DATA.
// ONLY ENABLE IT IF YOU'RE REALLY SURE WHAT YOU'RE DOING!
$rcmail_config['enable_installer'] = false;

// Log successful logins
$rcmail_config['log_logins'] = false;

$rcmail_config['delete_always'] = false;

// Minimal value of user's 'keep_alive' setting (in seconds)
// Must be less than 'session_lifetime'
$rcmail_config['min_keep_alive'] = 60;

/***** these settings can be overwritten by user's preferences *****/

// skin name: folder from skins/
// Шкура по дефолту (я указал свою)
$rcmail_config['skin'] = 'mvision';

// show up to X items in list view
$rcmail_config['pagesize'] = 40;

// use this timezone to display date/time
$rcmail_config['timezone'] = 'auto';

// is daylight saving On?
$rcmail_config['dst_active'] = (bool)date('I');

// prefer displaying HTML messages
$rcmail_config['prefer_html'] = TRUE;

// display remote inline images
// 0 - Never, always ask
// 1 - Ask if sender is not in address book
// 2 - Always show inline images
$rcmail_config['show_images'] = 0;

// compose html formatted messages by default
$rcmail_config['htmleditor'] = FALSE;

// show pretty dates as standard
$rcmail_config['prettydate'] = TRUE;

// save compose message every 300 seconds (5min)
$rcmail_config['draft_autosave'] = 300;

// default setting if preview pane is enabled
$rcmail_config['preview_pane'] = FALSE;

// focus new window if new message arrives
$rcmail_config['focus_on_new_message'] = true;

// Clear Trash on logout
$rcmail_config['logout_purge'] = FALSE;

// Compact INBOX on logout
$rcmail_config['logout_expunge'] = FALSE;

// Display attached images below the message body
$rcmail_config['inline_images'] = TRUE;

// Encoding of long/non-ascii attachment names:
// 0 - Full RFC 2231 compatible
// 1 - RFC 2047 for 'name' and RFC 2231 for 'filename' parameter (Thunderbird's default)
// 2 - Full 2047 compatible
$rcmail_config['mime_param_folding'] = 0;

// Set TRUE if deleted messages should not be displayed
// This will make the application run slower
$rcmail_config['skip_deleted'] = FALSE;

// Set true to Mark deleted messages as read as well as deleted
// False means that a message's read status is not affected by marking it as deleted
$rcmail_config['read_when_deleted'] = TRUE;

// When a Trash folder is not present and a message is deleted, flag
// the message for deletion rather than deleting it immediately.  Setting this to
// false causes deleted messages to be permanantly removed if there is no Trash folder
$rcmail_config['flag_for_deletion'] = FALSE;

// Default interval for keep-alive/check-recent requests (in seconds)
// Must be greater than or equal to 'min_keep_alive' and less than 'session_lifetime'
$rcmail_config['keep_alive'] = 60;

// If true all folders will be checked for recent messages
$rcmail_config['check_all_folders'] = FALSE;

// end of config file
?>

Добавим алиас в Apache:
[root@router /]# ee /usr/local/etc/apache/vhosts/aliases.conf
Alias /roundcube/ "/usr/local/www/roundcube/"
<Directory "/usr/local/www/roundcube">
        Order deny,allow
        Allow from all
</Directory>

и виртул-хост:
<VirtualHost *>
ServerAdmin admin@example.com
ServerName mail.example.com
DocumentRoot /usr/local/www/roundcube/
DirectoryIndex index.php index.php3 index.html
AddType application/x-httpd-php .php .php3
Action  application/x-httpd-php /cgi-bin/php-cgi
ErrorLog /var/log/webmail-error.log
CustomLog /var/log/webmail-custom.log combined
</VirtualHost>

Перегружаем web-сервер и заходим с браузера на mail.example.com:
18_1.png

после авторизации:
19_1.png

Если кому понравилась шкура, прилепил - mvision.tar.bz2, распаковываем ее в /usr/local/www/roundcube/skins.
Вот вроде и все.

Прикрепленный файлРазмер
mvision.tar_.bz2337.91 кб
Ваша оценка: Нет Средняя: 4.8 (9 votes)

Комментарии:


ur3ckr аватар

Все классно, единственно почему-то с этим скином не работает кнопка "Прикрепить файл". Скин по дефолту прикрепляет файлы.



admin аватар

Попробуй другим браузером, у меня работает.