メール設定 · 5 min read · Jan 10, 2026
Postfix、Courier、MySQL、SquirrelMailを使用した仮想ユーザーとドメイン (CentOS 4.8 i386) - ページ 5
18 SquirrelMailのインストール
SquirrelMailは、ユーザーがブラウザでメールを送受信できるウェブメールインターフェースです。この章では、SquirrelMailをインストールし、ユーザーがSquirrelMailインターフェースからメールアカウントのパスワードを変更できるように設定する方法を示します。
SquirrelMailをインストールするには、次のコマンドを実行します:
yum install squirrelmail php-pear-DBその後、Apacheを再起動します:
/etc/init.d/httpd restartSquirrelMailにはいくつかのプラグインがプリインストールされていますが、残念ながら、どれもMySQLデータベース内のメールパスワードを変更することはできません。しかし、手動でインストールできるChange SQL Passwordプラグインがあります:
cd /usr/share/squirrelmail/plugins
wget http://www.squirrelmail.org/countdl.php?fileurl=http%3A%2F%2Fwww.squirrelmail.org%2Fplugins%2Fchange_sqlpass-3.3-1.2.tar.gz
tar xvfz change_sqlpass-3.3-1.2.tar.gz
cd change_sqlpass
cp config.php.sample config.php次に、config.phpを編集し、設定に合わせて調整する必要があります。以下のように、$csp_dsn、$lookup_password_query、$password_update_queries、$password_encryption、$csp_salt_static、および$csp_delimiter変数を調整し、$csp_salt_queryをコメントアウトしてください:
vi config.php| [...] $csp_dsn = 'mysql://mail_admin:mail_admin_password@localhost/mail'; [...] $lookup_password_query = 'SELECT count(*) FROM users WHERE email = "%1" AND password = %4'; [...] $password_update_queries = array('UPDATE users SET password = %4 WHERE email = "%1"'); [...] $password_encryption = 'MYSQLENCRYPT'; [...] $csp_salt_static = 'LEFT(password, 2)'; [...] //$csp_salt_query = 'SELECT salt FROM users WHERE username = "%1"'; [...] $csp_delimiter = '@'; [...] |
完全なファイルは次のようになります:
| * 2002-2005 Paul Lesneiwski <[email protected]> * このプログラムはGPLの下でライセンスされています。詳細についてはCOPYINGを参照してください * * @package plugins * @subpackage Change SQL Password * */ // グローバル変数、プラグインを壊したくない限り、これに触れないでください // global $csp_dsn, $password_update_queries, $lookup_password_query, $force_change_password_check_query, $password_encryption, $csp_salt_query, $csp_salt_static, $csp_secure_port, $csp_non_standard_http_port, $csp_delimiter, $csp_debug, $min_password_length, $max_password_length, $include_digit_in_password, $include_uppercase_letter_in_password, $include_lowercase_letter_in_password, $include_nonalphanumeric_in_password; // csp_dsn // // 理論的には、Pearによってサポートされている任意のSQLデータベースがここでサポートされるべきです。 // DSN(データソース名)には、データベースバックエンドに接続するために必要な情報が含まれている必要があります。MySQLの例が以下に含まれています。 // DSN構文とサポートされているデータベースタイプのリストの詳細については、次を参照してください: // http://pear.php.net/manual/en/package.database.db.intro-dsn.php // //$csp_dsn = 'mysql://user:password@localhost/email_users'; $csp_dsn = 'mysql://mail_admin:mail_admin_password@localhost/mail'; // lookup_password_query // // このプラグインは常にユーザーの古いパスワードを // ログインパスワードと照合しますが、追加のチェックを行うこともできます。 // より安全にしたい場合は、データベースに対して追加のチェックを行うことができます。 // 追加のパスワードチェックが必要ない場合は、 // この設定を空にしてください。 // // これは、ユーザーとパスワードのペアがデータベースに見つかった場合に // 正の値を返すクエリです。 // // このクエリは1つの値(1行、1列)を返す必要があり、 // 値は理想的には1または0で、単にユーザー/パスワードペアが // 実際にデータベースに存在することを示します。 // // %1はこのクエリで完全なユーザー名に置き換えられます // (ドメインを含む)、例えば"[email protected]" // %2はこのクエリでユーザー名(ドメイン部分なし)に置き換えられます // 例えば"jose" // %3はこのクエリでドメイン名に置き換えられます、 // 例えば"example.com" // %4はこのクエリで現在の(古い) // パスワードに置き換えられます(他のプラグインの設定に応じた暗号化形式) // %5はこのクエリで現在の(古い) // パスワードに置き換えられます(暗号化されていないプレーンテキスト)。 // パスワード暗号化を使用しない場合、%4と%5は同じ値になりますが、 // %4には二重引用符が付いており、%5には付いていません。 // //$lookup_password_query = ''; // TERRIBLE SECURITY: $lookup_password_query = 'SELECT count(*) FROM users WHERE username = "%1" AND plain_password = "%5"'; //$lookup_password_query = 'SELECT count(*) FROM users WHERE username = "%1" AND crypt_password = %4'; $lookup_password_query = 'SELECT count(*) FROM users WHERE email = "%1" AND password = %4'; // password_update_queries // // パスワード変更の試行が行われるたびに実行されるSQLクエリの配列です。 // // ここに任意の数のクエリを含めることができます。 // クエリはここに示された順序で実行されます。 // // %1はすべてのクエリで完全なユーザー名に置き換えられます // (ドメインを含む)、例えば"[email protected]" // %2はすべてのクエリでユーザー名(ドメイン部分なし)に置き換えられます // 例えば"jose" // %3はすべてのクエリでドメイン名に置き換えられます、 // 例えば"example.com" // %4はすべてのクエリで新しいパスワードに置き換えられます // (他のプラグインの設定に応じた暗号化形式) // %5はすべてのクエリで新しいパスワードに置き換えられます // (暗号化されていないプレーンテキスト)- 注意! パスワード暗号化を使用しない場合、%4と%5は同じ値になりますが、 // %4には二重引用符が付いており、%5には付いていません。 // // $password_update_queries = array( // 'UPDATE users SET crypt_password = %4 WHERE username = "%1"', // 'UPDATE user_flags SET force_change_pwd = 0 WHERE username = "%1"', // 'UPDATE users SET crypt_password = %4, force_change_pwd = 0 WHERE username = "%1"', // ); $password_update_queries = array('UPDATE users SET password = %4 WHERE email = "%1"'); // force_change_password_check_query // // ユーザーがパスワードを変更する必要があるかどうかを示すフラグをチェックするクエリです。 // このクエリは1つの値(1行、1列)を返す必要があり、 // ユーザーがパスワードを変更する必要がない場合は0を、 // ユーザーが今すぐ変更する必要がある場合は1を返します。 // // この設定は、この機能を有効にしたくない場合は空の文字列にしてください。 // // %1はこのクエリで完全なユーザー名に置き換えられます // (ドメインを含む)、例えば"[email protected]" // %2はこのクエリでユーザー名(ドメイン部分なし)に置き換えられます // 例えば"jose" // %3はこのクエリでドメイン名に置き換えられます、 // 例えば"example.com" // //$force_change_password_check_query = 'SELECT IF(force_change_pwd = "yes", 1, 0) FROM users WHERE username = "%1"'; //$force_change_password_check_query = 'SELECT force_change_pwd FROM users WHERE username = "%1"'; $force_change_password_check_query = ''; // password_encryption // // データベースにパスワードを保存するために使用する暗号化方法は何ですか? // 次のいずれかを正確にそのまま使用してください: // // NONE パスワードはプレーンテキストとしてのみ保存されます // MYSQLPWD パスワードはMySQL password()関数を使用して保存されます // MYSQLENCRYPT パスワードはMySQL encrypt()関数を使用して保存されます // PHPCRYPT パスワードはPHP crypt()関数を使用して保存されます // MD5CRYPT パスワードは暗号化されたMD5アルゴリズムを使用して保存されます // MD5 パスワードはMD5ハッシュとして保存されます // //$password_encryption = 'MYSQLPWD'; $password_encryption = 'MYSQLENCRYPT'; // csp_salt_query // csp_salt_static // // 塩が必要な暗号化タイプは、どこでその塩を取得するかを知る必要があります。 // 定数の既知の塩値がある場合は、$csp_salt_staticに定義する必要があります。 // それ以外の場合は、その値を空のままにし、$csp_salt_queryの値を定義してください。 // // パスワードの暗号化に塩を必要としない場合は、両方の値を空のままにしてください。 // // クエリは、現在のユーザーのパスワードの塩値を返す必要があります。 // このクエリは、$csp_salt_staticが空でない限り無視されます。 // // %1はこのクエリで完全なユーザー名に置き換えられます // (ドメインを含む)、例えば"[email protected]" // %2はこのクエリでユーザー名(ドメイン部分なし)に置き換えられます // 例えば"jose" // %3はこのクエリでドメイン名に置き換えられます、 // 例えば"example.com" // //$csp_salt_static = 'LEFT(crypt_password, 2)'; //$csp_salt_static = '"a4"'; // MYSQLENCRYPTでこの形式を使用 //$csp_salt_static = '$2$blowsomefish$'; // PHPCRYPTでこの形式を使用 //$csp_salt_static = ''; $csp_salt_static = 'LEFT(password, 2)'; //$csp_salt_query = 'SELECT SUBSTRING_INDEX(crypt_password, '$', 1) FROM users WHERE username = "%1"'; //$csp_salt_query = 'SELECT SUBSTRING(crypt_password, (LENGTH(SUBSTRING_INDEX(crypt_password, '$', 2)) + 2)) FROM users WHERE username = "%1"'; //$csp_salt_query = 'SELECT salt FROM users WHERE username = "%1"'; //$csp_salt_query = ''; // csp_secure_port // // パスワード変更中にSSL暗号化を使用することを保証するには、 // HTTPSが提供されるポートにこれを設定します(443が一般的です)。 // ユーザーがパスワードを変更する際にHTTPS接続を強制したくない場合は、 // 0に設定します。 // // 特定のドメイン、ユーザー、またはサービスレベルに対してこの値をオーバーライドすることができます。 // Virtual Host Login(vlogin)プラグインを通じて、 // vlogin設定で$vlogin_csp_secure_portの値を設定することによって。 // $csp_secure_port = 0; //$csp_secure_port = 443; // csp_non_standard_http_port // // 標準HTTPウェブリクエストを非標準ポート(ポート80以外)で提供する場合は、 // そのポート番号をここに指定する必要があります。そうでない場合は0に設定します。 // // 特定のドメイン、ユーザー、またはサービスレベルに対してこの値をオーバーライドすることができます。 // Virtual Host Login(vlogin)プラグインを通じて、 // vlogin設定で$vlogin_csp_non_standard_http_portの値を設定することによって。 // //$csp_non_standard_http_port = 8080; $csp_non_standard_http_port = 0; // min_password_length // max_password_length // include_digit_in_password // include_uppercase_letter_in_password // include_lowercase_letter_in_password // include_nonalphanumeric_in_password // // 受け入れる最小および最大パスワードの長さを設定することができます。 // または、これらの設定を0のままにして、制限を適用しないことを示します。 // // 他の設定を有効にして、新しいパスワードに少なくとも1つの数字、大文字、小文字、および/または1つの非英数字が含まれているかどうかを確認します。 // $min_password_length = 6; $max_password_length = 0; $include_digit_in_password = 0; $include_uppercase_letter_in_password = 0; $include_lowercase_letter_in_password = 0; $include_nonalphanumeric_in_password = 0; // csp_delimiter // // システムにユーザー名が「@」以外の文字でユーザーとドメイン部分を区切る場合は、 // その文字をここに指定してください // //$csp_delimiter = '|'; $csp_delimiter = '@'; // デバッグモード // $csp_debug = 0; ?> |
Change SQL Passwordプラグインは、Compatibilityプラグインにも依存しており、次のようにインストールします:
cd /usr/share/squirrelmail/plugins
wget http://www.squirrelmail.org/countdl.php?fileurl=http%3A%2F%2Fwww.squirrelmail.org%2Fplugins%2Fcompatibility-2.0.14-1.0.tar.gz
tar xvfz compatibility-2.0.14-1.0.tar.gzcd /usr/share/squirrelmail/plugins/compatibility
patch -p0 < patches/compatibility_patch-1.4.8.diff次に、SquirrelMailの設定に移動し、SquirrelMailにCourierをPOP3およびIMAPサーバーとして使用することを伝え、Change SQL PasswordおよびCompatibilityプラグインを有効にします:
/usr/share/squirrelmail/config/conf.pl次のメニューが表示されます。指示に従ってナビゲートしてください:
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 >> <–D
SquirrelMail Configuration : Read: config.php
SquirrelMailを構築している間に、いくつかのサーバーでうまく機能する設定があり、他のサーバーではあまりうまく機能しないことがわかりました。IMAPサーバーを選択すると、このオプションはそのサーバーのためのいくつかの事前定義された設定を設定します。
すべてが正しいことを確認するために、まだ確認する必要があります。この設定はすべてを変更するものではありません。これにより変更される設定はほんの数個です。
IMAPサーバーを選択してください:
bincimap = Binc IMAP server
courier = Courier IMAP server
cyrus = Cyrus IMAP server
dovecot = Dovecot Secure IMAP server
exchange = Microsoft Exchange IMAP server
hmailserver = hMailServer
macosx = Mac OS X Mailserver
mercury32 = Mercury/32
uw = University of Washington’s IMAP server
quit = Do not change anything
Command >> <– courier
SquirrelMail Configuration : Read: config.php
SquirrelMailを構築している間に、いくつかのサーバーでうまく機能する設定があり、他のサーバーではあまりうまく機能しないことがわかりました。IMAPサーバーを選択すると、このオプションはそのサーバーのためのいくつかの事前定義された設定を設定します。
すべてが正しいことを確認するために、まだ確認する必要があります。この設定はすべてを変更するものではありません。これにより変更される設定はほんの数個です。
IMAPサーバーを選択してください:
bincimap = Binc IMAP server
courier = Courier IMAP server
cyrus = Cyrus IMAP server
dovecot = Dovecot Secure IMAP server
exchange = Microsoft Exchange IMAP server
hmailserver = hMailServer
macosx = Mac OS X Mailserver
mercury32 = Mercury/32
uw = University of Washington’s IMAP server
quit = Do not change anything
Command >> courier
imap_server_type = courier
default_folder_prefix = INBOX.
trash_folder = Trash
sent_folder = Sent
draft_folder = Drafts
show_prefix_option = false
default_sub_of_inbox = false
show_contain_subfolders_option = false
optional_delimiter = .
delete_folder = true
任意のキーを押して続行してください… <– キーを押す
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 >> <– 8
SquirrelMail Configuration : Read: config.php (1.4.0)
Plugins
Installed Plugins
1. delete_move_next
2. squirrelspell
3. newmail
Available Plugins:
4. message_details
5. fortune
6. compatibility
7. filters
8. info
9. administrator
10. spamcop
11. change_sqlpass
12. bug_report
13. calendar
14. listcommands
15. abook_take
16. sent_subfolders
17. mail_fetch
18. translate
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >> <–6 (または互換性プラグインの番号)
SquirrelMail Configuration : Read: config.php (1.4.0)
Plugins
Installed Plugins
1. delete_move_next
2. squirrelspell
3. newmail
4. compatibility
Available Plugins:
5. message_details
6. fortune
7. filters
8. info
9. administrator
10. spamcop
11. change_sqlpass
12. bug_report
13. calendar
14. listcommands
15. abook_take
16. sent_subfolders
17. mail_fetch
18. translate
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >> <–11 (またはchange_sqlpassプラグインの番号)
SquirrelMail Configuration : Read: config.php (1.4.0)
Plugins
Installed Plugins
1. delete_move_next
2. squirrelspell
3. newmail
4. compatibility
5. change_sqlpass
Available Plugins:
6. message_details
7. fortune
8. filters
9. info
10. administrator
11. spamcop
12. bug_report
13. calendar
14. listcommands
15. abook_take
16. sent_subfolders
17. mail_fetch
18. translate
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >> <–S
SquirrelMail Configuration : Read: config.php (1.4.0)
Plugins
Installed Plugins
1. delete_move_next
2. squirrelspell
3. newmail
4. compatibility
5. change_sqlpass
Available Plugins:
6. message_details
7. fortune
8. filters
9. info
10. administrator
11. spamcop
12. bug_report
13. calendar
14. listcommands
15. abook_take
16. sent_subfolders
17. mail_fetch
18. translate
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >> S
データがconfig.phpに保存されました
続行するにはEnterを押してください… <– ENTER
SquirrelMail Configuration : Read: config.php (1.4.0)
Plugins
Installed Plugins
1. delete_move_next
2. squirrelspell
3. newmail
4. compatibility
5. change_sqlpass
Available Plugins:
6. message_details
7. fortune
8. filters
9. info
10. administrator
11. spamcop
12. bug_report
13. calendar
14. listcommands
15. abook_take
16. sent_subfolders
17. mail_fetch
18. translate
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >> <–Q
最後に行う必要があるのは、/etc/squirrelmail/config_local.phpファイルを修正し、$default_folder_prefix変数をコメントアウトすることです。これを行わないと、SquirrelMailにログインした後に次のエラーメッセージが表示されます: Query: CREATE “Sent” Reason Given: Invalid mailbox name.
vi /etc/squirrelmail/config_local.php| |
これで、ブラウザでhttp://server1.example.com/webmailまたはhttp://192.168.0.100/webmailにアクセスしてSquirrelMailにアクセスできます。
メールアドレス(例: [email protected])とパスワードでログインします:

受信トレイにウェルカムメールが見つかるはずです:


パスワードを変更するには、[オプション]に移動し、[パスワードの変更]を選択します:

現在のパスワードを入力し、新しいパスワードを2回入力します:

SquirrelMailは、パスワードが正常に変更されたかどうかを教えてくれます:

19 参考文献
チュートリアル: Debian-SargeとPostfix 2.1を使用したISPスタイルのメールサービス: http://workaround.org/articles/ispmail-sarge/
Postfix + Quota: http://vhcs.net/new/modules/newbb/viewtopic.php?topic_id=3496&forum=17
Mail Passwords Encrypted using saslauthd: http://www.syscp.de/docs/public/contrib/cryptedmailpws
20 リンク
- Postfix MTA: http://www.postfix.org/
- Postfix Quota Patch: http://web.onda.com.br/nadal/
- phpMyAdmin: http://www.phpmyadmin.net/
- SquirrelMail: http://www.squirrelmail.org/
- CentOS: http://www.centos.org/
新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。