SquirrelMail
pop mail も良いが、出先で簡単に使うには webmail が重宝する。大手のプロバイダも無料で webmail サービスを行っている。ちょうど雑誌に特集が組んであったので、フリーの SquirrelMail をインストールする。
| Linux Server | since May.11 2003 |
|
|||
| Copyright sleepingbird, 1993- All rights reserved. | |||||
| Linux Server |
TOP > Linux Server > Webmail
pop mail も良いが、出先で簡単に使うには webmail が重宝する。大手のプロバイダも無料で webmail サービスを行っている。ちょうど雑誌に特集が組んであったので、フリーの SquirrelMail をインストールする。
SquirrelMail は php4 で動作するので、はじめに php4 をインストールする必要がある。 ついでに、MySQL もインストールする。
# apt-get install MySQL-client MySQL-devel MySQL-embedded MySQL-server MySQL-shared php php-apache2 php-devel php-pear php-mysql php-imap
# /etc/init.d/apache2 restart
<?
phpinfo();
?>
通常、インストールは apache2 の DocumentRoot である /var/www/html に行うが、ここではディレクトリ指定を
/var/www/qcp として行った。
最新の stable 版の SquirrelMail 1.4.9a を get し、DocumentRoot ディレクトリに解凍する。
$ cd /var/www/qcp (通常は /var/www/html )ディレクトリ名をアクセスしやすく変更した後、data ディレクトリのパーミッションとオーナーを web server のものに変更しておく。(httpd.conf の User と Group で定義したもの。default は両方とも apache)
$ wget http://www.squirrelmail.org/countdl.php?fileurl=http://prdownloads.sourceforge.net/squirrelmail/squirrelmail-1.4.9a.tar.gz
$ tar xzfv squirrelmail-1.4.9a.tar.gz
$ mv squirrelmail-1.4.9a webmaildataディレクトリが外部から見えないように、dataディレクトリに.htaccessが用意して有るので、それが有効になるように httpd.conf に次の行を追加しておく。
$ cd webmail
$ chmod 730 data
$ su
# chown -R apache:apache data
# exit
$
<Directory /var/*/public_html>
:
:
:
</Directory>
−−− ここから
# squirrelmail
<Directory /var/www/qcp/webmail/data>
AllowOverride Limit
</Directory>
<Directory /var/www/qcp/webmail>
SSLRequireSSL
</Directory>
−−− ここまで
$ cd webmail
$ wget http://www.squirrelmail.org/countdl.php?fileurl=http://prdownloads.sourceforge.net/squirrelmail/all_locales-1.4.9-20070106.tar.gz
$ tar xzfv all_locales-1.4.9-20070106.tar.gz
とりあえずメールの送受信が出来れば良いので、必要最小限の設定を行う。
設定メニューは、./configure で起動する。
./configure 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 off S Save data Q Quit Command >>次の項目を必要に応じ設定する。赤字は最低限設定する項目。
| SquirrelMail Configuration : Read: config.php (1.4.0) | ||||
| --------------------------------------------------------- | ||||
| Organization Preferences | : | |||
| 1. Organization Name | : | qcp.jp | 組織名、ログイン画面やタイトルなどに表示される | |
| 2. Organization Logo | : | ../images/sm_logo.png | ログイン画面に表示される画像 | |
| 3. Org. Logo Width/Height | : | (308/111) | 上の画像のサイズ。幅/高さ | |
| 4. Organization Title | : | SquirrelMail $version | ログイン画面に表示されるタイトル | |
| 5. Signout Page | : | ログアウト時に表示されるページ | ||
| 6. Default Language | : | ja_JP | デフォルトの言語 | |
| 6. Top Frame | : | _top | トップのフレームの名前 | |
| 7. Provider link | : | http://www.squirrelmail.jp/ | MailBox 画面のリンク先 url | |
| 8. Provider name | : | SquirrelMail | 上の url の表示文字 | |
| : | ||||
| R Return to Main Menu | : | Main Menu へ戻る | ||
| C. Turn color on | : | メニューのカラー表示 | ||
| S Save data | : | 設定値の保存 | ||
| Q Quit | : | 終了 | ||
| SquirrelMail Configuration : Read: config.php (1.4.0) | ||||
| --------------------------------------------------------- | ||||
| Server Settings | ||||
| General | ||||
| ------- | ||||
| 1. Domain | : | qcp.jp | 送信者のドメイン名 | |
| 2. Invert Time | : | false | タイムゾーン誤動作対応用 | |
| 3. Sendmail or SMTP | : | SMTP | 通常はSMTP | |
| A. Update IMAP Settings : localhost:143 (other) | IMAP サーバー名と port 番号 | |||
| B. Update SMTP Settings : localhost:25 | SMTP サーバー名と port 番号 | |||
| SquirrelMail Configuration : Read: config.php (1.4.0) | ||||
| --------------------------------------------------------- | ||||
| Folder Defaults | ||||
| 1. Default Folder Prefix | : | UW-IMAPの場合のみ設定する項目 設定不可? |
||
| 2. Show Folder Prefix Option | : | false | 上の追加設定項目 | |
| 3. Trash Folder | : | Trash | Trash(ゴミ箱)フォルダ名、日本語不可 変更不可 |
|
| 4. Sent Folder | : | Sent | Sent(送信済)フォルダ名、日本語不可 変更不可 |
|
| 5. Drafts Folder | : | Drafts | Drafts(草稿)フォルダ名、日本語不可 変更不可 |
|
| 6. By default, move to trash | : | true | 削除したファイルを自動的に Trash フォルダに移動しない場合 false | |
| 7. By default, move to sent | : | true | 送信済みのメールを自動的に Sent フォルダに移動しない場合 false | |
| 8. By default, save as draft | : | true | 草稿を自動的に Drafts フォルダに保存しない場合 false | |
| 9. List Special Folders First | : | true | 一覧表示するときに Trash,Sent,Drafts を最初に表示する場合 true | |
| 10. Show Special Folders Color | : | true | Trash,Sent,Drafts に色をつけて表示する場合 true | |
| 11. Auto Expunge | : | true | 削除マークを付けるだけでゴミ箱に移動しない場合 false | |
| 12. Default Sub. of INBOX | : | true | ||
| 13. Show 'Contain Sub.' Option | : | false | ||
| 14. Default Unseen Notify | : | 3 | 未読の通知のタイプを指定 1 = 通知しない 2 = INBOX(受信箱)だけ通知する 3 = 全てのフォルダを通知する |
|
| 15. Default Unseen Type | : | 2 | 未読の表示の形式を指定 1 = 未読の数だけ 2 = 未読/総数の形式 |
|
| 16. Auto Create Special Folders | : | true | 特別フォルダを自動的に作る。 | |
| 17. Folder Delete Bypasses Trash | : | false | フォルダもゴミ箱で削除する場合 true | |
| 18. Enable /NoSelect folder fix | : | false | ||
| SquirrelMail Configuration : Read: config.php (1.4.0) | ||||
| --------------------------------------------------------- | ||||
| General Options | ||||
| 1. Data Directory | : | ../data/ | データを保存するディレクトリ | |
| 2. Attachment Directory | : | $data_dir | 添付ファイルを一時的に保存するディレクトリ | |
| 3. Directory Hash Level | : | 0 | ユーザデータディレクトリの分割。ユーザーが少なければ 0 で良い。 | |
| 4. Default Left Size | : | 150 | 左側(フォルダリスト)のフレームの幅(ピクセル) | |
| 5. Usernames in Lowercase | : | true | ユーザ名に大文字も使用する場合 false | |
| 6. Allow use of priority | : | true | メールの優先度を使用する | |
| 7. Hide SM attributions | : | false | ログイン画面の version 情報や、SquirrelMailのサイトへのリンク表示を隠すか否か | |
| 8. Allow use of receipts | : | true | 受取通知の機能を使用する | |
| 9. Allow editing of identity | : | true/true | 複数のFrom(差出人)アドレスを使う | |
| 10. Allow server thread sort | : | true | スレッド表示を有効にする | |
| 11. Allow server-side sorting | : | false | ソートをサーバ側で行う場合は true 、PHP なら false | |
| 12. Allow server charset search | : | true | 日本語の場合は true | |
| 13. Enable UID support | : | true | ||
| 14. PHP session name | : | SQMSESSID | ||
| SquirrelMail Configuration : Read: config.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 | ||
| SquirrelMail Configuration : Read: config.php (1.4.0) | ||||
| --------------------------------------------------------- | ||||
| Message of the Day (MOTD) | ||||
| 1 Edit the MOTD | ||||
| SquirrelMail Configuration : Read: config.php (1.4.0) | ||||
| --------------------------------------------------------- | ||||
| Language preferences | ||||
| 1. Default Language | : | ja_JP | 言語設定 | |
| 2. Default Charset | : | iso-2022-jp | 文字セット | |
| 3. Enable lossy encoding | : | false | ||
設定が一応終わったら、稼働させてみる。
PHP4 は稼働確認できているので、IMAP を稼働させる。
IMAP パッケージを apt-get でインストールし、inetd.conf を修正して inetd を再起動しておく。
# apt-get install uw-imap
# vi /etc/inetd.conf
# Pop and imap mail services et al
#
#pop-2 stream tcp nowait root /usr/sbin/tcpd in.qpopper
imap stream tcp nowait root /usr/sbin/tcpd imapd↑ # をとる
# /etc/init.d/inet restart
このままでは、http 通信のためログイン時の password が垂れ流し状態になっているので
secure_login プラグイン を導入して https 通信にする。
ついでに、無操作時に自動でログアウトする Timeout_User 、自動でファイルを保存する
quick_save、それと受信したメールヘッダーからアドレス帳にメールアドレスを追加する
address_add も導入する。なお、共通モジュールとして Compatibility プラグインは必ず入れておく必要がある。プラグインの入手はこちらから。
導入は簡単で、プラグインディレクトリに展開した後、./configure でメニュー番号8を選択するとプラグイン一覧が表示されるので、組み込みたいプラグイン番号を指定して
enter キーを押せば゛Available Plugins: から Installed Plugins リストに移動する。確認したら
save quit すれば良い。
$ cd /var/www/qcp/webmail/plugins
$ tar zxfv compatibility-2.0.6.tar.gz
$ tar zxfv secure_login-1.2-1.2.8.tar.gz
$ tar zxfv timeout_user-1.1.1-0.5.tar.gz
$ tar zxfv quicksave-2.3-1.1.0.tar.gz
$ tar zxfv address_add-2.1-1.4.0.tar.gz
$ cd secure_login
$ cp config.php.sample config.php
$ vi config.php
// if you want user sessions to remain in SSL only if they originally came
// in thru SSL (this plugin didn't need to redirect them), set the following
// to one:
//
$remain_in_https_if_logged_in_using_https = 1;
ここを1にすることによってすべて SSL 通信になる。
# vi /etc/apache2/conf/httpd.conftimeout_usr config.php に標準ログアウト時間等があるので直しておく。
# squirrelmail
<Directory /var/www/qcp/webmail/data>
AllowOverride Limit
</Directory>
−−− ここから<IfDefine SSL>
<Directory /var/www/qcp/webmail>
SSLRequireSSL
</Directory>
</IfDefine>
−−− ここまで
# /etc/init.d/apache2 restart
$ cd timeout_user
$ vi config.php
| filters | 受信メールの振り分け |
| mail_fetch | pop3 メールの受信 |
| calendar | 予定表 |
| message_details | ヘッダを含めてデコードされていない生のメールを別ウインドウで 表示できる |
| 名 前 | 機 能 | Version | 特記 |
|---|---|---|---|
| Compatibility | v 1.2.11 と v.1.4.0 のプラグインを共通化する為のプラグイン。必須。 | 2.0.6 | |
| Secure Login | https ログインをサポート。 | 1.2-1.2.8 | 要設定 config.php httpd.conf 上で解説 |
| Timeout User | 無操作時、自動でタイムアウトログオフ。メール作成中を感知しないので、Quick Save は必須。 | 1.1.1-0.5 | 要設定 config.php |
| Quick Save | メール作成時に、一定時間毎にバックアップする。 | 2.3-1.1.0 | |
| Address Add | 受信したメールヘッダーからアドレス帳にメールアドレスを追加する。 | 2.0-1.2.8 | |
| Addressbook Import-Export | アドレスブックをCSVでインポート/エクスポートする。 | 1.0-1.4.4 | |
| addgraphics | ログイン後、画面左上にドメイン毎の画像を表示する。 | 232-1.0.3 | 要設定 config.php 下で解説 |
| Mail Forward | メールの転送設定。 | 0.4.1-1.4.0 | install 下で解説 |
| Sent Confirmation | メール送信後のメッセージ表示と送信先のアドレス帳追加。 | 1.6-1.2 | 展開後の INSTALL ファイに従って設定 |
$ cd addgraphics
$ cp config.php.typical.one.domain config.php
$ vi config.php
画像ファイル名を指定
$left_image = '../images/sleepingbird_webmail.gif';
画像 alt を指定
$left_image_alt = 'sleepingbird.net';
画像リンクを指定
$left_image_url = 'http://www.sleepingbird.net/';
画像サイズを指定
$image_width = 80;
$image_height = 40;
$ cd mail_fwd/fwdfileVineLinux の場合、変更の必要はなかった。ただし、ファイル末尾の一行が編集確認フラグとなっているので、削除しないとコンパイルが先に進まない。
$ vi config.mk
実行モジュール wfwd のインストール先を指定する。
BINDIR = /usr/local/sbin
webserver の実行ユーザー名を指定する。
(default は www-data と説明されていたが、入手した file は apache になっていた。)
WEBUSER = apache
# REMOVE THIS after you've changed WEBUSER to the right valueコンパイル&インストールする。
REMOVE_THIS=YES
$ make設定ファイルを用意する。
$ su
# make install
# exit
$ cd ../今回はコンパイル時にディレクトリ指定を変更しなかったので編集の必要はなかった。
$ cp config_dist.php config.php
$ vi config.php
インストールディレクトリを指定する。
$mail_fwd_wfwd_binary = "/usr/local/sbin/wfwd";
添付ファイルサイズの変更は、/etc/php.ini の次の部分を変更して、apache を再起動する。
# vi /etc/php.ini併せて、postfix の main.cf でもファイルサイズを拡張して再起動しておく。
; Maximum allowed size for uploaded files.
upload_max_filesize = 25M
memory_limit = 60M
post_max_size = 60M
# /etc/rc.d/init.d/apache2 restart
# vi /etc/postfix/main.cfmailbox_size_limit に 0 を指定すると無制限となる。
; Mail box size
mailbox_size_limit = 0
message_size_limit = 25600000
# /etc/rc.d/init.d/postfix reload
サイトの移行時には、次のファイルを固めて移動する。
/var/spool/mail 下のメールファイルを移行
webmail/data 下のユーザー設定ファイルを移行
/home 下の .mailboxlist Sent Trash Drafts を移行
特定の受信メールが文字化けする。
当初は一部の携帯電話メールを転送した場合に発生していただけだったので無視していたが、このサーバーで使用している FormMail でも発生することが分かった。
原因は受信メールのヘッダ中 Content-Type: text/plain;charset= の記述が無いか SquirrelMail の想定外だった場合、キャラクタセットを
US-ASCII してしまうということらしい
。さらに試してみると MIME-Version: の記述がない場合も同様な振る舞いをする事が確認できた。
早速、メーリングリストのとおりパッチを当ててみたが回避できない。パッチリストの $squirrelmail_language == 'ja_JP'
の比較がうまくいかない。config/config.php の記述を確認してみたら $squirrelmail_default_language
= 'ja_JP' となっていたので訂正してみたがやはりだめ。そこで、どうせ日本語のキャラクタセットしか使う予定はないので、すべて強制的に日本語セットに設定する様に
functions/mime.php にパッチを当てた。
場所は 250行目付近。
$ vi functions/mime.php
function translateText(&$body, $wrap_at, $charset) {
global $where, $what; /* from searching */
global $color; /* color theme */
require_once(SM_PATH . 'functions/url_parser.php');
/* charset setting forced! */
$charset = $default_charset;
/* */