完全な仮想メールサーバ/Web アクセス

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Complete Virtual Mail Server/Web Access and the translation is 75% complete.

はじめに

E-mail でよく使われる機能のひとつが web メールアクセスです。アクセス方法としてもっぱら web メールのみを使用するユーザもいれば、自身のシステムが利用できないときにバックアップとして使用するユーザもいます。利用可能な選択肢は複数ありますが、mail-client/squirrelmailmail-client/roundcube がもっともよく使用されるものでしょう。帯域が重要な問題である場合には Squirrelmail が使用でき、そうでない場合は roundcube がおすすめで、この記事でも roundcube に着目します。

roundcube をインストールする

Roundcube はその設定をデータベースに保存することができます。ローカルのアドレス帳や個人情報なども、そこに保存することができます。

Here there are several options available. Use a local, per vhost based SQLite storage pool, use a postgres/mysql database per vhost or have all vhosts share the same database. There can be advantages for any of the above options. If webmail, for various domains, is on the same host as the imap server, then using one database for all domains is fine and can be an advantage. It could be desired that each domain, each vhost gets its own webmail interface (different skin and plugins) where all users could still log in. Meaning in the event of one of the vhosts webmail being broken, they can still access their e-mail normally using a different vhost. Whether the users settings 'live' in all vhosts or not, is based on the imap server. Roundcube bases its user id on the mail_host e.g. the imap server and thus when using localhost the user 'profile' is identical everywhere.

USE flags for mail-client/roundcube A browser-based multilingual IMAP client with an application-like user interface

change-password Allow users to change passwords through Roundcube
enigma Add dependencies to support server-side GnuPG signing and/or encryption through the enigma plugin
exif Add support for reading EXIF headers from JPEG and TIFF images
fileinfo Use the dev-lang/php fileinfo extension to guess the mime_type of attachments
ldap Add dependencies to support connecting to an LDAP address book server
mysql Add mySQL Database support
postgres Add support for the postgresql database
spell Add dictionary support
sqlite Add support for sqlite - embedded sql database
ssl Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security)
vhosts Add support for installing web-based applications into a virtual-hosting environment
zip Enable support for ZIP archives

メモ
sqlite を使用しない場合は postgres または mysql のみが必要です。

適切な USE フラグを選択したら、roundcube が emerge できるはずです:

root #emerge --ask mail-client/roundcube

これは roundcube をホストにのみインストールし、vhost にはインストールしません。

root #webapp-config -I -h webmail.example.com -d roundcube roundcube 1.0.5
メモ
webapp-config でエラーになる場合は、代わりに次の構文を使用してみてください:
root #webapp-config -h webmail.example.com -d roundcube -I roundcube 1.0.6

Postgres を使用する

セキュリティ上の深刻な懸念事項がないなら、roundcube によって使用されるすべてのデータベースにアクセスするためのデータベースユーザが、ひとつだけ必要です:

root #createuser -U postgres -D -P -R -S roundcube
Enter password for new role: $password
Enter it again: $password

Roundcube もデータベースを必要とします。ドメインごとに異なるデータベースを使用する場合は、それぞれ異なる名前を選択する必要があるでしょう:

root #createdb -U postgres roundcubemail -O roundcube
メモ
Having roundcube in a separate directory is incredibly useful. Installing (and testing) a second webmail client, for example, or migrating to a new one, can be so much easier having it on the same host. However, the standard URL, webmail.example.com won't open up roundcube anymore. To fix this, create the following file as index.php in the root of htdocs directory.
ファイル index.php
'"`UNIQ--pre-00000005-QINU`"'

Roundcube を設定する

Configuring roundcube has become incredible easy. Just visit http://webmail.example.com/roundcube/installer/ and follow the on screen instructions, correcting any issues as they pop up.

Below are the old instructions when manually creating the config.inc.php file. The installer should still be used to create the database, which it has a button for.

Roundcube を設定する (手動)

Configuring roundcube is as simple as editing two configuration files in /var/www/webmail.example.com/htdocs/roundcube/config/.

To access the database only the following line needs to be changed. The user name chosen earlier is roundcube. Replace pass in this line with the password chosen earlier:

ファイル /var/www/webmail.example.com/htdocs/roundcube/config/db.inc.phpデータベースアクセス
$rcmail_config['db_dsnw'] = 'pgsql://roundcube:pass@localhost/roundcubemail';

Next listed are the essential changes required for roundcube operation. More can be done to personalize the setup:

ファイル /var/www/webmail.example.com/htdocs/roundcube/config/main.inc.phpRoundcube 設定
-$rcmail_config['default_host'] = '';
+$rcmail_config['default_host'] = 'localhost';
 
-$rcmail_config['smtp_server'] = '';
+$rcmail_config['smtp_server'] = 'localhost';
 
 // SMTP username (if required) if you use %u as the username Roundcube
 // will use the current username for login
+$rcmail_config['smtp_user'] = '';
-$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'] = '';
+$rcmail_config['smtp_pass'] = '%p';
 
 // 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';
+$rcmail_config['des_key'] = '$supersecret24bytestring';

Starting with Roundcube version 0.6, Roundcube needs to have the fully qualified names for the default storage folders, such as Trash, Drafts etc:

ファイル /var/www/webmail.example.com/htdocs/roundcube/config/main.inc.php完全修飾されたフォルダ名をセットアップする
// NOTE: Use folder names with namespace prefix (INBOX. on Courier-IMAP)
-$rcmail_config['drafts_mbox'] = 'Drafts';
+$rcmail_config['drafts_mbox'] = 'INBOX.Drafts';
 
// NOTE: Use folder names with namespace prefix (INBOX. on Courier-IMAP)
-$rcmail_config['junk_mbox'] = 'Junk';
+$rcmail_config['junk_mbox'] = 'INBOX.Junk';
 
// NOTE: Use folder names with namespace prefix (INBOX. on Courier-IMAP)
-$rcmail_config['sent_mbox'] = 'Sent';
+$rcmail_config['sent_mbox'] = 'INBOX.Sent';
 
// NOTE: Use folder names with namespace prefix (INBOX. on Courier-IMAP)
-$rcmail_config['trash_mbox'] = 'Trash';
+$rcmail_config['trash_mbox'] = 'INBOX.Trash';
 
// NOTE: Use folder names with namespace prefix (INBOX. on Courier-IMAP)
-$rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent', 'Junk', 'Trash');
+$rcmail_config['default_imap_folders'] = array('INBOX', 'INBOX.Drafts', 'INBOX.Sent', 'INBOX.Junk', 'INBOX.Trash');

roundcube をテストする

http://webmail.example.com/ から web メールにログインし、メールボックスが表示されることをテストしてください。メールの送信も正しく機能するはずです。