SquirrelMail(Webメール)


出先からのメールの送受信の為に apop befor smtp を設定しました。
この形態での使用では、出先にメーラの使える環境を必要とします。
ノートPCと携帯電話を常に持ち歩くのであれば問題ありませんが、これは大変です。

IE等のwebブラウザはインターネットカフェ等で使うことが可能です。
web上でのメールの送受信(webメール)を考えます。

webメーラーの選定


次の方針で webメーラー を選定します。
  • メールの格納方式は mailbox なので、これに対応していること
  • ブラウザに依存していないこと
  • JavaScript等を使用していないこと
これらの条件をにあった webメーラー として、SquirrelMail を見つけました。


SquirrelMail の特徴は次の通りです
  • もちろん、無料
  • imap4だけに対応
  • PHPだけで書かれている
  • 豊富なプラグインが用意されている 等々

筆者のサーバには imap4 環境はありません。
SquirrelMail と imap4 環境を構築します。

SquirrelMail のインストールと設定


いつものように、apt-get を使用します
# apt-get update
# apt-get install squirrelmail
       :
       :
       :
Server alk.dip.jp:443 (RSA)
Enter pass phrase: ←途中でRSAのパスフレーズ聞かれた(2回)ので入力


Run /usr/sbin/squirrelmail-configure as root to configure/upgrade config.←最後にこのコメントを表示して終了
インストール終了後、下記のコマンドを実行せよと言われるので、言われるがままに実行します。
/usr/sbin/squirrelmail-configure(このコマンドで、SquirrelMail の設定を行う)
# /usr/sbin/squirrelmail-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 on
S Save data
Q Quit

Command >> 10←言語設定を選択
SquirrelMail Configuration : Read: config.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 >> 1←デフォルトの言語設定メニューを選択

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

[en_US]: ja_JP←デフォルトの言語にja_JPを指定
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Language preferences
1. Default Language : ja_JP
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 >> 2←デフォルトCharsetの設定メニューを選択

This option controls what character set is used when sending
mail and when sending HTML to the browser.

This option is used only when default language is 'en_US'.

[iso-8859-1]: iso-2022-jp←デフォルトのCharsetにiso-2022-jpを指定
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Language preferences
1. Default Language : ja_JP
2. Default Charset : ∫so-2022-jp
3. Enable lossy encoding : false

R Return to Main Menu
C Turn color on
S Save data
Q Quit

Command >> r←rでメインメニューへ戻る
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 >> 2←サーバの設定メニューを選択
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings

General
-------
1. Domain : trim(implode('', file('/etc/'.(file_exists('/etc/mailname')?'mail':'host').'name')))
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 >> a←imap設定メニューを選択
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings

General
-------
1. Domain : trim(implode('', file('/etc/'.(file_exists('/etc/mailname')?'mail':'host').'name')))
2. Invert Time : false
3. Sendmail or SMTP : SMTP

IMAP Settings
--------------
4. IMAP Server : localhost
5. IMAP Port : 143
6. Authentication type : login
7. Secure IMAP (TLS) : false
8. Server software : other
9. Delimiter : detect

B. Update SMTP Settings : localhost:25
H. Hide IMAP Server Settings

R Return to Main Menu
C Turn color on
S Save data
Q Quit

Command >> 8←imapのサーバソフトウェア設定メニューを選択

Each IMAP server has its own quirks. As much as we tried to stick
to standards, it doesn't help much if the IMAP server doesn't follow
the same principles. We have made some work-arounds for some of
these servers. If you would like to use them, please select your
IMAP server. If you do not wish to use these work-arounds, you can
set 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
hmailserver = hMailServer
other = Not one of the above servers
[other]: uw←uw-imapdを使用予定なので uw を入力
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings

General
-------
1. Domain : trim(implode('', file('/etc/'.(file_exists('/etc/mailname')?'mail':'host').'name')))
2. Invert Time : false
3. Sendmail or SMTP : SMTP

IMAP Settings
--------------
4. IMAP Server : localhost
5. IMAP Port : 143
6. Authentication type : login
7. Secure IMAP (TLS) : false
8. Server software : uw
9. Delimiter : detect

B. Update SMTP Settings : localhost:25
H. Hide IMAP Server Settings

R Return to Main Menu
C Turn color on
S Save data
Q Quit

Command >>r←メインメニューへ戻る

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 >> s←ここまでの設定内容を保存

Data saved in config.php
Press enter to continue...
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 >> q←SquirrelMail設定メニューの終了


Exiting conf.pl.
You might want to test your configuration by browsing to
http://your-squirrelmail-location/src/configtest.php
Happy SquirrelMailing!

#

以上で、SquirrelMailの設定は終了です。
次に imap の設定を行います。

uw-imapdのインストールと設定


私のサーバにはメール取り出し(MUA)用のプログラムとして qpopper を使用しています。
これは、imap に対応していません。
SquirrelMail は、imap のみに対応しています。
したがって、imap用のプログラムを導入する必要があります。
imap用プログラムもいくつかありますが、uw-imapd を使うことにしました。
理由は、今の私のサーバ構成に相性が良さそうと感じたからです。
(実際にベストな選択かどうか分かりません・・・・)

いつもの通り apt-get でインストールを開始します
# apt-get install uw-imapd

次の画面を表示します。
ドキ!!何だか文字化けを起こしています。
Maildir がどうのこうのと書かれているようですが、さっぱり分かりません。
筆者のサーバは Maildir 方式ではなく Mailbox 方式を使っています。
したがって、Noでも良さそうな気はしますが、訳が分からないので、デフォルトのYesを選択します。




分からなかったら imap2 と imaps を選択せよ(デフォルト)となっています。
指示に従ってデフォルトのままOkとしました。


これで、uw-imapd のインストールは終了です。
それでは、SquirrelMail を動かしてみましょう、と言いたい所なのですが、どうやって?

SquirrelMail用Apache2の設定


殆どのプログラムは、/etc の下に環境設定ファイルが置かれます。
SquirrelMail の場合も例外ではないと考え /etc の下を探してみました。
すると、予想通りに /etc/squirrelmail のフォルダが出来ていました。
その中置かれていた apache.conf の内容は次の通りです

/etc/squirrelmail/apache.conf の内容
Alias /squirrelmail /usr/share/squirrelmail ドキュメントルート/squirrelmail にアクセスされたら
/usr/share/squirrelmail にリダイレクトする
<Directory /usr/share/squirrelmail> /usr/share/squirrelmail の設定開始
    php_flag register_globals off phpのグローバル変数アクセスを許可
    Options Indexes FollowSymLinks →Indexes
index.htmlがない場合は、ファイル一覧を表示
→FollowSymLinks
このディレクトリ内のシンボリックリンクをたどることを許可
    <IfModule mod_dir.c> mod_dir.cがロードされていれば
        DirectoryIndex index.php /(スラッシュ)で終わるURLでリクエストが
あった場合、index.php へリダイレクトする
    </IfModule>
</Directory>

筆者のサーバでは、SquirrelMailをSSLサイトに置きます。
上記に示した apache.conf の内容をSSLサイトの設定ファイルに追記して、Apche2 を再起動させます。

このとき、Alias行だけを変更しました。
変更前 変更後
Alias /squirrelmail /usr/share/squirrelmail Alias /ssl_01/squirrelmail /usr/share/squirrelmail

これで、下記URLをアクセスするとSquirrelMailが起動するはずです。
https://alk.dip.jp/ssl_01/squirrelmail/

しかし、ログインできず!!!


uw-imapdの設定


ここまでの設定でwebメールが、使えるはずですがログインに失敗します。
原因を探してググってみると次のページを見つけました。
http://www.nurs.or.jp/~ogochan/linux/uw-imapd.html

uw-imapd はデフォルトで通常ログインを禁止しています
通常ログインを使いたければ、/etc/c-client.cf を作成し下記内容を記述する必要があります。
/etc/c-client.cf の内容
I accept the risk for IMAP toolkit.
set disable-plaintext 0

SquirrelMail はSSLサイトに置きます。
盗聴に関しては、安全です。
通常ログインを有効にして、SquirrelMail へログインを試みました。
ようやく、ログインに成功しました。

使用感



色々試してみましたが、良さそうな感じです。
以前 SqWebMail(別のwebメール) の日本語パッチ版を使ったことがありますが、半角カタカナの小文字が文字化けしていました。
SquirrelMail では、問題なく使えています。