Squirrelmailの構築

最新バージョンをダウンロードします。
最新版をSquirrelMail日本サイトからダウンロードします
また、RedHat用の日本語版のRPMパッケージがあるスコットヒューズさんのページからダウンロードできます。
SquirrelMailの使用方法はこちら沢田さんのホームページで詳しく掲載されています。


Squirrelmailのインストール状況確認
# rpm -qa | grep squirrelmail
squirrelmail-1.2.11-1

Squirrelmailが入っている場合には削除します。
# rpm -e squirrelmail-1.2.11-1

squirrelmail 1.4.3aをインストールします。
スコットヒューズさんのページからダウンロードしたRedHat用の最新版squirrelmail-ja-1.4.3a-1_rh9.noarch.rpmをインストールします。(2004年7月現在)、FedoraCore4は、squirrelmail-ja-1.4.5-1_fc4.noarch.rpm(2005年7月現在)

ダウンロード先場所のカレントディレクトリに移動してください。
# rpm -ivh squirrelmail-ja-1.4.3a-1_rh9.noarch.rpm
警告: Preparing...    ########################################### [100%]
1:squirrelmail-ja     ########################################### [100%]

squirrelmailの設定ファイルは /etc/squirrelmail/config.php ですが、/usr/share/squirrelmail/config/conf.plのperlスクリプトで設定した方が簡単ですが、CGIが使用可能になっていることが前提になります。
http://ドメイン/webmail/ ですぐに使える状態になりますが、このままではエラーになりますのでオーナー変更します。ここでは、/etc/httpd/conf/httpd.confで設定したユーザーとグループをnobodyに変更しているものとしています。
# chown -R nobody:nobody /var/lib/squirrelmail/prefs
# chown -R nobody:nobody /var/spool/squirrelmail/attach

squirrelmailの設定を/usr/share/squirrelmail/config/conf.plで設定します。
ツールが起動すると以下のような画面が表示されるので、選択や入力後はEnterで実行します。(ここでは、sendmailとuw-imapを使用しての設定になりますが、他のソフト使用の場合はその環境に合わせて設定してください。)
以下の設定項目で多少squirrelmailのバージョンによって違う場合があります。

1.まずはOrganization Preferencesで基本的な設定を行うため、1を選択する。
# /usr/share/squirrelmail/config/conf.pl

SquirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
Main Menu --
1. Organization Preferences
2. Server Settings
3. Folder Defaults
4. General Options
5. Themes
6. Address Books (LDAP)
7. Message of the Day (MOTD)
8. Plugins
9. Database
D. Set pre-defined settings for specific IMAP servers
C. Turn color on
S. Save data
Q. Quit
Command >> 1
2.下記のような画面が表示されるので、default languageを選択(6を選択)し、ja_JPを確認する。違っていれば変更します。 変更後 r でメインメニューに戻る。


SquirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
Organization Preferences
1. Organization Name
2. Organization Logo
3. Org. Logo Width/Height
4. Organization Title
5. Signout Page
6. Default Language
7. Top Frame
8. Provider link
9. Provider name
: SquirrelMail
: ../images/sm_logo.png
: (308/111)
: SquirrelMail $version
: ../signout.php
: ja_JP ←確認、en_USの場合下記のように修正
: _top
: http://www.squirrelmail.org/
: SquirrelMail
R. Return to Main Menu
C. Turn color on
S. Save data
Q. Quit
Command >> 6


SquirrelMail attempts to set the language in many ways.
If itcan not figure it out in another way, it will default to thislanguage.
Please use the code for the desired language.

[en_US]: ja_JP ←入力します。


SquirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
Organization Preferences
1. Organization Name
2. Organization Logo
3. Org. Logo Width/Height
4. Organization Title
5. Signout Page
6. Default Language
7. Top Frame
8. Provider link
9. Provider name
R.Return to Main Menu
C. Turn color on
S. Save data
Q. Quit

Command >> r


: SquirrelMail
: ../images/sm_logo.png
: (308/111)
: SquirrelMail $version
:
: ja_JP
: _top
: http://www.squirrelmail.org/
: SquirrelMail








同様に以降も設定していく。
メインメニューで、Server Settings(2を選択)でドメイン名とimapサーバ(デフォルトはuw)の確認をしますが、違っていれば変更します。


自ドメインの設定をしますので、1を選択します。

SquirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
Server Settings General
--------
1. Domain
2. Invert Time
3. Sendmail or SMTP
A. Update IMAP Settings
B. Update SMTP Settings
R. Return to Main Menu
C. Turn color on
S. Save data
Q. Quit

Command >> 1


: mydomain.com
: false
: Sendmail
: localhost:143 (cyrus)
: localhost:25








he domain name is the suffix at the end of all email addresses.
Iffor example, your email address is jdoe@myorg.com, then your domainwould be myorg.com.

[mydomain.com]: abcde.com ←自ドメインを入力します。


次に、imapサーバuwを確認します。他になっている場合は変更しますのでaを選択してから8を選択します。

quirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
Server Settings General
--------
1. Domain
2. Invert Time
3. Sendmail or SMTP
A. Update IMAP Settings
: localhost:143 (cyrus)
R. Return to Main Menu
C. Turn color on
S. Save data
Q. Quit

Command >> a


: abcde.com
: false
: Sendmail
: localhost:143 (cyrus)
: localhost:25








SquirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
Server SettingsGeneral
--------
1. Domain
2. Invert Time
3. Sendmail or SMTP
: abcde.com
: false
: SMTPIMAP Settings

--------------

4. IMAP Server
5. IMAP Port
6. Authentication type
7. Secure IMAP (TLS)
8. Server software
9. Delimiter
B. Update SMTP Settings
H. Hide IMAP Server Settings
R. Return to Main Menu
C. Turn color on
S. Save data
Q. Quit

Command >> 8


: localhost
: 143
: login
: false
: uw
: detect
: localhost:25









Each IMAP server has its own quirks.

As much as we tried to stickto standards, it doesn't help much if the IMAP server doesn't followthe same principles.
We have made some work-arounds for some ofthese servers.
If you would like to use them, please select yourIMAP server.
If you do not wish to use these work-arounds, you canset this to "other", and none will be used.

cyrus = Cyrus IMAP server
uw = University of Washington's IMAP server
exchange = Microsoft Exchange IMAP server
courier = Courier IMAP server
macosx = Mac OS X Mailserver
other = Not one of the above servers

[cyrus]: uw ←を入力します。


メニューにもどりますので、rを選択します。

SquirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
Server SettingsGeneral
--------
1. Domain
2. Invert Time
3. Sendmail or SMTP
--------------
4. IMAP Server
5. IMAP Port
6. Authentication type7. Secure IMAP (TLS)
8. Server software
9. Delimiter
B. Update SMTP Settings
H. Hide IMAP Server Settings
R. Return to Main Menu
C. Turn color on
S. Save data
Q. Quit

Command >> r


: acorn.zive.net
: false
: SMTPIMAP Settings



: localhost
: 143
: login
: false
: uw
: detect
: localhost:25







メインメニューで、General Options(4を選択)でDefault Charsetの確認iso-2022-jpであることを確認、違う場合は(iso-8859-1 -> iso-2022-jp)を行うので1を選択します。

SquirrelMail Configuration : Read: config_default.php (1.4.0)
---------------------------------------------------------
General Options
1. Default Charset
2. Data Directory
3. Attachment Directory
4. Directory Hash Level
5. Default Left Size
6. Usernames in Lowercase
7. Allow use of priority
8. Hide SM attributions
9. Allow use of receipts
10. Allow editing of identity
11. Allow server thread sort
12. Allow server-side sorting
13. Allow server charset search
14. Enable UID support
15. PHP session name
R. Return to Main Menu
C. Turn color on
S. Save data
Q. Quit

Command >> 1


: iso-2022-jp ←確認(違う場合は修正します。)
: ../data/
: $data_dir
: 0
: 150
: false
: true
: false
: true
: true/true
: false
: false
: true
: true
: SQMSESSID








This option controls what character set is used when sendingmail and when sending HTML to the browser. Do not set thisto US-ASCII, use ISO-8859-1 instead. For cyrillic, it is bestto use KOI8-R, since this implementation is faster than mostof the alternatives

[iso-8859-1]: iso-2022-jp ←iso-2022-jpを入力します。


以上で終了です。
データをセーブ(sを入力)し、qを入力してconfigureは終了。
※ Sendmail or SMTPの設定では、メールサーバーをSendmail使用している場合はSendmailになりますが、他Postfixなどのメールサーバ使用している場合はSMTPで設定しましょう。また、ここでは、uw-imapで設定していますが、他のimap使用の場合もその環境で設定してください。(courierタイプのimapなどは処理が早いようなのでおすすめですね)

実はこのままではやや大きめのメールを送信するとPHPの初期のメモリーサイズがやや小さめに設定されているため送信時にエラーが出て送れないという問題がありますのでメモリーサイズを増やします。
/etc/php.iniというファイルを編集する必要があります。
変更箇所は以下の部分になります。

# vi /etc/php.ini
;
;;;;;;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
file_uploads = Off ←OffからONに変更します。

; Temporary directory for HTTP uploaded files (will use system default if not specified).
;upload_tmp_dir =

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M


今時添付ファイルが2M程度だと苦しいので、以下3行を探し送信サイズを10MB程度にディレクトリのBOXサイズを50MB程度に修正します。

memory_limit = 50M ←8Mから50Mに修正
post_max_size = 50M ←2Mから50Mに修正
upload_max_filesize = 10M ←2Mから10Mに修正


保存して終了。


あと、このままではPHPの送受信サイズが500KBくらいのサイズ程度っとなっていますので/etc/httpd/conf.d/php.conf も修正します。PHPのファイルサイズがデフォルトでは、500KBくらいのサイズがリミットになっていますので、サイズを少し上げます。
※PHP5.x.xバージョンになると以下部分がありませんので<Files *.php>〜</Files>を追記します。
# vi /etc/httpd/conf.d/php.conf
#
# Cause the PHP interpreter handle files with a .php extension.
#
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 524288 → 52428800 ←ここの数字を変更します(500K→50M)。
</Files>


保存して終了
httpdを再起動して完了です。
# service httpd restart

最後にhttp://www.ドメイン/webmail/ でプラウザから起動してみますが、セキュリティ上危険です。squirrelmailは、SSLが使用可能なのでhttps://www.ドメイン/webmail/でアクセスしましょう。

セキュリティの警告画面がでたら、OKをクリックしてから、リスのログイン画面が表示すればOKです。ユーザー名とパスワード入力してログインすれば画像のように表示されれば文字化けなどないようなので問題ないと思います。


セキュリィティ対策
外部からアクセスするのに平面でパスワードが流れてしまうのでは危険なので、SSL使用でいきますのでhttpでアクセスしてきたらhttpsにredirectするようにします。(プラグインからの設定でSSL化が可能ですが下記の方が簡単)
# vi /usr/share/squirrelmail/index.php
<?php header("Location: https://www.ドメイン/webmail/src/login.php\r\n");?>
もしかしたら改行の\r\nを入れて開けなかったら\r\nを外して見てください。

エラー対処
squirrelmail設定後、エラーなどが出てどうしても開けない時の対処方法。
FedoraCore6のPHP5.1以上バージョン使用になるとエラーが結構でますのでパーミッション等、メールボックスの容量、ディレクトリーが存在しないなどでエラーが出ますのでそれぞれ対処する必要があります。
特に最初にログイン画面が開けないなどの場合はパーミッションのアクセス権限で開けない場合が多いです。対処するには、/etc/php.iniファイルの「diplay_error = On」にしてsquirrelmailを開いて見ればエラー内容等などでディレクトリーの場所が特定出来ますのでその場所のパーミッションの権限を755にすれば解決出来る場合が有ります。
例えば、以下のディレクトリーやファイル等のパーミションを確認して見てください。
/usr/share/squirrelmail/index.php
/var/lib/squirrelmail/prefs
/var/spool/squirrelmail/attach

SquirrelMailを使ってメールを送信すると次のようなエラーが出力されて、送信済みボックスや、ドラフトボックスにメールが収納されないという問題でメールの送信自体は相手側に問題なく送信されています。
サーバの応答: Error in IMAP command received by server.
サーバの応答: Missing literal in APPEND

解決方法としては、viエディターなどで以下のPHPファイルを開いてください。
※Windowsでは\マークになりますが、Linuxではバックスラッシュで解釈します。
/usr/share/squirrelmail/functions/以下に、
imap_general.php 下記のファイルを開いて赤字になっている関数の構文記述エラー(パスの指定が違っているために上記画像のようなエラーになるようですね。)を探して下さい。

# vi /usr/share/squirrelmail/functions/imap_general.php ←設定ファイル編集

/** ←かなり最終行に近い887行以下
* Saves a message to a given folder -- used for saving sent messages
*/
function sqimap_append ($imap_stream, $sent_folder, $length) {
fputs ($imap_stream, sqimap_session_id() . " APPEND \"$sent_folder\" (\\Seen) \{$length}\r\n");
$tmp = fgets ($imap_stream, 1024);
sqimap_append_checkresponse($tmp, $sent_folder);
}

ファイルの最終ラインくらいの891行目付近の下記赤字の部分を変更してください。
fputs ($imap_stream, sqimap_session_id() . " APPEND \"$sent_folder\" (\\Seen) \{$length}\r\n");
  
fputs ($imap_stream, sqimap_session_id() . " APPEND \"$sent_folder\" (\\Seen) {".$length."}\r\n");

以上の対処方法で解決出来る事があります。

戻る          次へ