Wbeメールで非常に有名な、SquirrelMailについて構築の手順などを説明します。
SquirrelMailについては、こちら を参照してください。
SquirrelMailが動作するのに必要なものとして、下記に示すものが必要です。
Apache
PHP
Perl
上記プログラムに加え、外部公開するウェブメールならば、通信内容を暗号化する必要があるでしょうから、
opensslも必要と思われます。
yum install php-mbstring
SSL暗号化通信を行う場合には、下記のモジュールを追加インストールする必要があります。
yum install mod_ssl
それぞれ必要なプログラムは、httpd PHP Perl に記載されているので、そちらを参考にしてください。
opensslに関しては、httpdの項目に記載していますので、参考にしてください。
SquirrelMailのファイルを入手して、展開、設定、運用までを順を追って説明します。
SquirrelMailは、PHPで動作するプログラムですので、PHPのインストールを確認してください。
PHP Version 1.4.1以上
詳細なインストール手順に関しては、こちらを参照してください。
また、構築しようとしているOSが、CentOS6.xならば、こちらを参照してください。
SquirrelMail本家のインストールマニュアルによると、下記のパラメータの設定をする必要があります。
PHPの準備
We recommend the following PHP settings:
register_globals off - This is a dangerous setting when enabled, and is not generally needed for most recent PHP applications. We no longer release security advisories for issues only exploitable with this setting turned on because it has long been a well-known weakness in PHP (and has been removed from PHP 6). Note that you can easily enable it only for a single legacy application that may require it while keeping the default off for the rest of your applications.
magic_quotes_{runtime, gpc, sybase} off - SquirrelMail may work with any of these turned on, but if you experience stray backslashes in your mail or other strange behaviour, it may be advisable to turn them off.
file_uploads on - This is needed if your users want to attach files to their emails.
safe_mode on or off - Turning safe mode on in SquirrelMail's case is not much more secure than having it off. When it is enabled, incompatibilities with some functionality may arise (see our safe mode notes).
Perlの確認
SquirrelMailの環境設定には、Perlスクリプトで動くため、Perlがインストールされていることが必要です。
SquirrelMailは、IMAPを使用します(標準設定時)。
IMAPがインストールされていることを確認してください。
詳細な設定に関しては、こちらを参照してください。
こちら へアクセスして、最新版のSquirrelMailを入手してください。
執筆時(2012/10/17)の最新バージョンは、1.4.22 です。
インストールしようと思うサーバに、SSHでログインします。
先ほどのダウンロードサイトへアクセスして、最新版のリンクをコピーし、下記のように直接サーバ上でダウンロードするのが一番手っ取り早いです。
$ wget http://squirrelmail.org/countdl.php?fileurl=http%3A%2F%2Fprdownloads.sourceforge.net%2Fsquirrelmail%2Fsquirrelmail-webmail-1.4.22.tar.gz
rootユーザに切り替わり、ファイルを展開し、展開したディレクトリをwebmailに変更します。
cd /var/www
tar zxvf squirrelmail-webmail-1.4.22.tar.gz
mv squirrelmail-webmail-1.4.22 webmail
cd webmail
mkdir -p /var/local/squirrelmail/{data,attach}
chown -R nobody:nobody data
vi /etc/http/conf.d/squirrelmail.conf
Alias /webmail /var/www/webmail
<Directory "/var/www/webmail">
DirectoryIndex index.php
AllowOverride All
order deny,allow
allow from ALL
</Directory>
/etc/rc.d/init.d/httpd restart
※上記設定のままだと、Webmailへの操作内容が丸見えなので、SSLによる暗号化通信を
施す必要があります。
設定には、SquirrelMailの設定と、Apacheの設定、2つの設定を行う必要があります。
展開したディレクトリに移動します。
# cd webmail
設定プログラムを起動します。
# ./configure
MainMenu
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1. Organization Preferences
2. Server Settings
3. Folder Defaults
4. General Options
5. Themes
6. Address Books
7. Message of the Day (MOTD)
8. Plugins
9. Database
10. Languages
D. Set pre-defined settings for specific IMAP servers
C Turn color on
S Save data
Q Quit
Command >>
Organization Preferences
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Organization Preferences
1. Organization Name : SquirrelMail
2. Organization Logo : ../images/sm_logo.png
3. Org. Logo Width/Height : (308/111)
4. Organization Title : SquirrelMail $version
5. Signout Page :
6. Top Frame : _top
7. Provider link : http://squirrelmail.org/
8. Provider name : SquirrelMail
R Return to Main Menu
C Turn color on
S Save data
Q Quit
Command >>
Server Settings
SquirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
Server Settings
General
-------
1. Domain : example.com
2. Invert Time : false
3. Sendmail or SMTP : SMTP
A. Update IMAP Settings : localhost:143 (other)
B. Update SMTP Settings : localhost:25
R Return to Main Menu
C Turn color on
S Save data
Q Quit
Command >>
Folder Defaults
SquirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
Folder Defaults
1. Default Folder Prefix :
2. Show Folder Prefix Option : false
3. Trash Folder : INBOX.Trash
4. Sent Folder : INBOX.Sent
5. Drafts Folder : INBOX.Drafts
6. By default, move to trash : true
7. By default, save sent messages : true
8. By default, save as draft : true
9. List Special Folders First : true
10. Show Special Folders Color : true
11. Auto Expunge : true
12. Default Sub. of INBOX : true
13. Show 'Contain Sub.' Option : false
14. Default Unseen Notify : 2
15. Default Unseen Type : 1
16. Auto Create Special Folders : true
17. Folder Delete Bypasses Trash : false
18. Enable /NoSelect folder fix : false
R Return to Main Menu
C Turn color on
S Save data
Q Quit
Command >>
Themes
SquirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
Themes
1. Change Themes
Default Plain Blue
Sand Storm Deep Ocean
Slashdot Purple
Forest Ice
Sea Spray Blue Steel
Dark Grey High Contrast
Black Bean Burrito Servery
Maize BluesNews
Deep Ocean 2 Blue Grey
Dompie Methodical
Greenhouse Effect (Changes) In The Pink (Changes)
Kind of Blue (Changes) Monostochastic (Changes)
Shades of Grey (Changes) Spice of Life (Changes)
Spice of Life - Lite (Changes) Spice of Life - Dark (Changes)
Holiday - Christmas Darkness (Changes)
Random (Changes every login) Midnight
Alien Glow Dark Green
Penguin Minimal BW
Redmond Net Style
Silver Steel Simple Green
Wood Bluesome
Simple Green 2 Simple Purple
Autumn Autumn 2
Blue on Blue Classic Blue
Classic Blue 2 Powder Blue
Techno Blue Turquoise
2. CSS File :
R Return to Main Menu
C Turn color on
S Save data
Q Quit
Address Books
SquirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
Address Books
1. Change LDAP Servers
2. Use Javascript Address Book Search : false
3. Global file address book :
4. Allow writing into global file address book : false
5. Allow listing of global file address book : true
6. Allowed address book line length : 2048
R Return to Main Menu
C Turn color on
S Save data
Q Quit
Command >>
Message of the Day (MOTD)
SquirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
Message of the Day (MOTD)
1 Edit the MOTD
R Return to Main Menu
C Turn color on
S Save data
Q Quit
Command >>
Plugins
SquirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
Plugins
Installed Plugins
Available Plugins:
1. administrator
2. bug_report
3. calendar
4. delete_move_next
5. demo
6. filters
7. fortune
8. info
9. listcommands
10. mail_fetch
11. message_details
12. newmail
13. sent_subfolders
14. spamcop
15. squirrelspell
16. test
17. translate
R Return to Main Menu
C Turn color on
S Save data
Q Quit
Command >>
Database
SquirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
Database
1. DSN for Address Book :
2. Table for Address Book : address
3. DSN for Preferences :
4. Table for Preferences : userprefs
5. Field for username : user
6. Field for prefs key : prefkey
7. Field for prefs value : prefval
8. DSN for Global Address Book :
9. Table for Global Address Book : global_abook
10. Allow writing into Global Address Book : false
11. Allow listing of Global Address Book : false
R Return to Main Menu
C Turn color on
S Save data
Q Quit
Command >>
Language preferences
SquirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
Language preferences
1. Default Language : en_US
2. Default Charset : iso-8859-1
3. Enable lossy encoding : false
R Return to Main Menu
C Turn color on
S Save data
Q Quit
Command >>
設定項目は非常に多岐にわたってありますが、最低限設定をしなければならなところを説明します。
Server Settings
1. Domain
任意のドメイン名を入力してください
Language preferences
1. Default Language
ja_JP
2. Default Charset
iso-2022
作業用ディレクトリの作成
作業ディレクトリの作成と、アクセス権の設定を行います。
mkdir -p /var/local/squirrelmail/{data,attach}
cd /var/local/squirrelmail
chgrp -R apache attach
chmod 730 attach
chown apache:apache /var/local/squirrelmail/data
chown apache:apache /var/local/squirrelmail/attach
日本語化対応
wget http://jaist.dl.sourceforge.net/sourceforge/squirrelmail/ja_JP-1.4.18-20090526.tar.bz2
最新版は、下記サイトで確認する (2013/04/09時点では、1.4.18までしかなかった)
http://sourceforge.net/projects/squirrelmail/files/locales/
cd /tmp
mkdir a
cd a
tar jxvf ja_JP-1.4.18-20090526.tar.bz2
./install
Please enter path to your squirrelmail installation: /var/www/webmail/local
すべての設定が一通り終わったら、動作確認を行ってください。
http://[serverIP/ServerURL]/webmail/src/configtest.php
SquirrelMail configtest
SquirrelMail configtest
This script will try to check some aspects of your SquirrelMail configuration and point you to errors whereever it can find them. You need to go run conf.pl in the config/directory first before you run this script.
SquirrelMail version:
Config file version:
Config file last modified:
1.4.22
1.4.0
09 April 2013 17:10:15
Checking PHP configuration...
PHP version 5.3.3 OK.
Running as N/A(N/A) / N/A(N/A)
display_errors:
error_reporting: 22527
variables_order OK: GPCS.
PHP extensions OK. Dynamic loading is disabled.
ERROR: You have configured PHP not to allow short tags (short_open_tag=off). This shouldn't be a problem with SquirrelMail or any plugin coded coded according to the SquirrelMail Coding Guidelines, but if you experience problems with PHP code being displayed in some of the pages and changing setting to "on" solves the problem, please file a bug report against the failing plugin. The correct contact information is most likely to be found in the plugin documentation.
Checking paths...
ERROR: I cannot write to data dir (/var/local/squirrelmail/data/)!
エラーが表示されたところが、設定が不足しているところです。
SquirrlMail configtest Complete
SquirrelMail configtest
This script will try to check some aspects of your SquirrelMail configuration and point you to errors whereever it can find them. You need to go run conf.pl in the config/directory first before you run this script.
SquirrelMail version:
Config file version:
Config file last modified:
1.4.22
1.4.0
09 April 2013 17:29:28
Checking PHP configuration...
PHP version 5.3.3 OK.
Running as N/A(N/A) / N/A(N/A)
display_errors:
error_reporting: 22527
variables_order OK: GPCS.
PHP extensions OK. Dynamic loading is disabled.
Checking paths...
Data dir OK.
Attachment dir OK.
Plugins are not enabled in config.
Themes OK.
Default language OK.
Base URL detected as: http://eagle.org/webmail/src (location base autodetected)
Checking outgoing mail service....
SMTP server OK (220 eagle.org ESMTP Postfix)
Checking IMAP service....
IMAP server ready (* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.)
Capabilities: * CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN
Checking internationalization (i18n) settings...
gettext - Gettext functions are available. On some systems you must have appropriate system locales compiled.
mbstring - Mbstring functions are available.
recode - Recode functions are unavailable.
iconv - Iconv functions are available.
timezone - Webmail users can change their time zone settings.
Checking database functions...
not using database functionality.
Congratulations, your SquirrelMail setup looks fine to me!
この状態になったら、ログイン出来ます。
SquirrelMailの運用をする上で、いろいろとあると便利なチューニングパラメータ情報
下記ファイル:timezones.cfg をダウンロードして、 webmail/local ディレクトリ以下にコピーします。
デフォルトでは、送信添付ファイルサイズが 2M になっています。
このサイズを拡張できるようにするためには、 /etc/php.ini を編集します。
vi /etc/php.ini
879行めくらい
upload_max_filesize = 2M
ここを大きくしてください。
※ただし、ここだけを大きくしても、Postfix 側の問題もあるので、極端なサイズを指定するのは止めた方がいいです。
5M 程度!? が、妥当かもしれない
vi /var/www/webmail/functions/i18n.php
設定パラメータ
case 'decodeheader':
$ret = str_replace("\t", "", $ret);
if (preg_match('/=\?([^?]+)\?(q|b)\?([^?]+)\?=/i', $ret))
$ret = @mb_decode_mimeheader($ret);
$ret = @mb_convert_encoding($ret, 'EUC-JP', 'ASCII,JIS,EUC-JP,UTF-8,SJIS');
break;
case 'downloadfilename':
$useragent = func_get_arg(2);
if (strstr($useragent, 'Windows') !== false ||
strstr($useragent, 'Mac_') !== false) {
$ret = mb_convert_encoding($ret, 'UTF-8', 'AUTO');
} else {
$ret = mb_convert_encoding($ret, 'EUC-JP', 'AUTO');
}
break;
すべてのアカウントに対して、共有のアドレス帳を利用したい場合、グローバルアドレス(Shared Address)
を用いることになります。
SquirrelMailの共有アドレス帳は、EUC コードで参照されるため、必ず作成したアドレス帳を文字コード変換しなければなりません。
DVD-ROM(CentOS 6.2)からのインストールだとこう入力します。
rpm -Uvh nkf-2.0.8b-6.2.el6.i686.rpm
インターネットからのインストールならば、
yum install nkf
/var/local/squirrelmail/dataにファイルを作成します。
cd /var/local/squirrelmail/data
vi glocal_abook.utf8
書式は下記のように書きます。
ニックネーム|名|姓|メールアドレス|情報
※それぞれの区切り文字は、| (パイプ:SHIFT+\)です。
また、メールアドレスの最後に空改行を入れると、読み込みエラーとなりますので注意してください。
例:
太郎くん|太郎|山田|t.Yamada@example.com|営業 1課
作成したグローバルアドレスは、UTF-8形式の文字コードなので、EUCに変換しなければなりません。
nkf -e global_abook.utf8 > global_abook
SquirrelMailの環境設定で、グローバルアドレスを使用するように設定します。
cd /var/www/webmail
./configure
6. Address Book
3. Global file address book
global_abook
s
q
Squirrel Mailにログインして、アドレス帳をクリックすれば、 共通アドレス帳 が表示されています。
通常は、ユーザのパスワード変更を行おうとした場合、コンソールから、passwd コマンドを用いて変更すると思いますが、
下記の方法を用いると、SquirrelMail 上から、パスワードの変更が出きるようになります。
事前準備として、poppassd というデーモンソフトが必要となるらしい
しかし、CentOS 6.x では、パッケージとして存在していません。
ここからダウンロードしてくる必要が有ります。
gcc poppassd.c -o poppassd -lcrypt
出来上がった実行プログラムをコピーします。
cp poppassd /usr/local/bin
※上記方法では、うまくいかなかったので、この方法は現時点で停止しておきます。
別の方法を模索する。
Ubuntuのサイトから、ソースをダウンロードしてコンパイルします。
poppassd_1.8.5.orig.tar.gz
適当なディレクトリ(/tmp など)に移動して、
tar zxvf poppassd_1.8.5.orig.tar.gz
pam に関するヘッダ情報が不足していると怒られたので、追加する。
yum install -y pam-devel
README に記載されているように実行する
make
コンパイルして出来た実行プログラムを、コピーする
cp poppassd /usr/sbin
poppassd のサービス登録を行います。
vi /etc/servicies
poppassd 106/tcp
xinetd のインストールを行います。
yum install xinetd
poppassd のサービスを追加登録します。
vi /etc/xinetd.d/poppassd
service poppassd
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/sbin/poppassd
log_on_success += HOST DURATION
log_on_failure += HOST
}
pam 設定ファイルを記述します
vi /etc/pam.d/poppassd
#%PAM-1.0
auth required /lib/security/pam_pwdb.so shadow nullok
account required /lib/security/pam_pwdb.so
password required /lib/security/pam_cracklib.so retry=3
password required /lib/security/pam_pwdb.so use_authtok nullok
rsyslog.conf に設定を追加します。
vi /etc/rsyslog.conf
local4.err /var/log/poppassd
サービスを開始します
/etc/rc.d/init.d/xinetd start
サービスの稼働状況を確認します。
netstat -at | grep poppassd
tcp 0 0 *:poppassd *:* LISTEN 13317/xinetd
サービスの自動起動設定をする。
chkconfig xinetd on
Plugins サイトを確認します。
changePasswd をダウンロードします。
change_pass-3.1-1.4.0.tar.gz
※2009/10/09 以降 開発が止まっているようだが、他のも同様のようです。
プラグインのあるディレクトリに移動します。
cd /var/www/webmail/plugins
ファイルを展開します。
tar zxvf change_pass-3.1-1.4.0.tar.gz
コンフィグファイルを編集して、プラグインを使用するようにします。
../configure
8. Plugins
7. change_pass (番号は環境によって変わります)
s
q
Empty Filder
empty_folders-2.0.1-1.2.tar.gz