1 views
実現する機能
Gmail、Hotmail、Yahoo!メール、そしてレンタルサーバーに来るメールすべてを自宅のメールサーバーで一覧、確認できるようにしています。使っているのはWebブラウザ上でメールができるWebmailシステムSquirrelMailです。
事前準備
※Webサーバー、リポジトリの追加(RPMforge、EPEL)Webサーバー間通信内容暗号化、メールサーバー(要IMAP)が構築済であること
SquirrelMailのインストール
[root@ufuso ~]# yum --enablerepo=epel -y install squirrelmail ← SquirrelMail インストール Installed: squirrelmail.noarch 0:1.4.22-3.el6 Complete! [root@ufuso ~]# cd /usr/share/squirrelmail/plugins/ ← pluginsフォルダへ移動 [root@ufuso plugins]# wget http://www.squirrelmail.org/plugins/compatibility-2.0.16-1.0.tar.gz ← 最新のプラグインをダウンロード `compatibility-2.0.16-1.0.tar.gz' に保存中 100%[======================================>] 41,497 35.0K/s 時間 1.2s 2013-12-15 20:33:13 (35.0 KB/s) - `compatibility-2.0.16-1.0.tar.gz' へ保存完了 [41497/41497] [root@ufuso plugins]# wget http://www.squirrelmail.org/plugins/empty_trash-1.4-1.2.2.tar.gz ← 最新のプラグインをダウンロード `empty_trash-1.4-1.2.2.tar.gz' に保存中 100%[======================================>] 2,715 --.-K/s 時間 0s 2013-12-15 20:33:20 (75.7 MB/s) - `empty_trash-1.4-1.2.2.tar.gz' へ保存完了 [2715/2715] [root@ufuso plugins]# wget http://www.squirrelmail.org/plugins/secure_login-1.4-1.2.8.tar.gz ← 最新のプラグインをダウンロード `secure_login-1.4-1.2.8.tar.gz' に保存中 100%[======================================>] 16,993 28.8K/s 時間 0.6s 2013-12-15 20:33:31 (28.8 KB/s) - `secure_login-1.4-1.2.8.tar.gz' へ保存完了 [16993/16993] [root@ufuso plugins]# tar zxvf compatibility-2.0.16-1.0.tar.gz ← ファイルを展開 [root@ufuso plugins]# tar zxvf empty_trash-1.4-1.2.2.tar.gz ← ファイルを展開 [root@ufuso plugins]# tar zxvf secure_login-1.4-1.2.8.tar.gz ← ファイルを展開 [root@ufuso plugins]# rm -f *.tar.gz ← ダウンロードファイルの削除 [root@ufuso plugins]# cd ← ルートディレクトリへ戻る |
■SquirrelMailの設定
[root@ufuso ~]# /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 >> 1 ← 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 off S Save data Q Quit Command >> 5 ← Signout Page選択 When users click the Sign Out button they will be logged out and then sent to signout_page. If signout_page is left empty, (hit space and then return) they will be taken, as normal, to the default and rather sparse SquirrelMail signout page. []: /webmail ← 入力 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 : /webmail 6. Top Frame : _top 7. Provider link : http://squirrelmail.org/ 8. Provider name : SquirrelMail R Return to Main Menu C Turn color off 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 off S Save data Q Quit Command >> 2 ← Server Settings選択 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Server Settings General ------- 1. Domain : localhost 2. Invert Time : false 3. Sendmail or SMTP : Sendmail A. Update IMAP Settings : localhost:143 (uw) B. Change Sendmail Config : /usr/sbin/sendmail R Return to Main Menu C Turn color off S Save data Q Quit Command >> 1 ← Domain選択 The domain name is the suffix at the end of all email addresses. If for example, your email address is jdoe@example.com, then your domain would be example.com. [localhost]: ufuso.dip.jp ← 自ドメイン名入力 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Server Settings General ------- 1. Domain : ufuso.dip.jp 2. Invert Time : false 3. Sendmail or SMTP : Sendmail A. Update IMAP Settings : localhost:143 (uw) B. Change Sendmail Config : /usr/sbin/sendmail R Return to Main Menu C Turn color off S Save data Q Quit Command >> 3 ← Sendmail or SMTP選択 You now need to choose the method that you will use for sending messages in SquirrelMail. You can either connect to an SMTP server or use sendmail directly. 1. Sendmail 2. SMTP Your choice [1/2] [1]: 2 ← SMTP選択 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Server Settings General ------- 1. Domain : ufuso.dip.jp 2. Invert Time : false 3. Sendmail or SMTP : SMTP A. Update IMAP Settings : localhost:143 (uw) B. Update SMTP Settings : localhost:25 R Return to Main Menu C Turn color off S Save data Q Quit Command >> A ← Update IMAP Settings選択 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Server Settings General ------- 1. Domain : ufuso.dip.jp 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 : / B. Update SMTP Settings : localhost:25 H. Hide IMAP Server Settings R Return to Main Menu C Turn color off S Save data Q Quit Command >> 4 ← IMAP Server選択 This is the hostname where your IMAP server can be contacted. [localhost]: ufuso.dip.jp ← 自IMAP Server名入力 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Server Settings General ------- 1. Domain : ufuso.dip.jp 2. Invert Time : false 3. Sendmail or SMTP : SMTP IMAP Settings -------------- 4. IMAP Server : ufuso.dip.jp 5. IMAP Port : 143 6. Authentication type : login 7. Secure IMAP (TLS) : false 8. Server software : uw 9. Delimiter : / B. Update SMTP Settings : localhost:25 H. Hide IMAP Server Settings R Return to Main Menu C Turn color off S Save data Q Quit Command >> 8 ← Server software選択 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. 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 gmail = IMAP access to Google mail (Gmail) accounts other = Not one of the above servers [uw]: dovecot ← dovecot入力 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Server Settings General ------- 1. Domain : ufuso.dip.jp 2. Invert Time : false 3. Sendmail or SMTP : SMTP IMAP Settings -------------- 4. IMAP Server : ufuso.dip.jp 5. IMAP Port : 143 6. Authentication type : login 7. Secure IMAP (TLS) : false 8. Server software : dovecot 9. Delimiter : / B. Update SMTP Settings : localhost:25 H. Hide IMAP Server Settings R Return to Main Menu C Turn color off S Save data Q Quit Command >> 9 ← Delimiter This is the delimiter that your IMAP server uses to distinguish between folders. For example, Cyrus uses '.' as the delimiter and a complete folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect' but if you are sure you know what delimiter your server uses, you can specify it here. To have it autodetect the delimiter, set it to 'detect'. [/]: detect ← detect入力 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Server Settings General ------- 1. Domain : ufuso.dip.jp 2. Invert Time : false 3. Sendmail or SMTP : SMTP IMAP Settings -------------- 4. IMAP Server : ufuso.dip.jp 5. IMAP Port : 143 6. Authentication type : login 7. Secure IMAP (TLS) : false 8. Server software : dovecot 9. Delimiter : detect B. Update SMTP Settings : localhost:25 H. Hide IMAP Server Settings R Return to Main Menu C Turn color off S Save data Q Quit Command >> B ← Update SMTP Settings選択 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Server Settings General ------- 1. Domain : ufuso.dip.jp 2. Invert Time : false 3. Sendmail or SMTP : SMTP SMTP Settings ------------- 4. SMTP Server : localhost 5. SMTP Port : 25 6. POP before SMTP : false 7. SMTP Authentication : none 8. Secure SMTP (TLS) : false 9. Header encryption key : A. Update IMAP Settings : ufuso.dip.jp:143 (dovecot) H. Hide SMTP Settings R Return to Main Menu C Turn color off S Save data Q Quit Command >> 4 ← SMTP Server選択 This is the hostname of your SMTP server. [localhost]: ufuso.dip.jp ← 自SMTPサーバー名入力 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Server Settings General ------- 1. Domain : ufuso.dip.jp 2. Invert Time : false 3. Sendmail or SMTP : SMTP SMTP Settings ------------- 4. SMTP Server : ufuso.dip.jp 5. SMTP Port : 25 6. POP before SMTP : false 7. SMTP Authentication : none 8. Secure SMTP (TLS) : false 9. Header encryption key : A. Update IMAP Settings : ufuso.dip.jp:143 (dovecot) H. Hide SMTP Settings R Return to Main Menu C Turn color off S Save data Q Quit Command >> 7 ← SMTP Authentication選択 If you have already set the hostname and port number, I can try to automatically detect the mechanisms your SMTP server supports. Auto-detection is *optional* - you can safely say "n" here. Try to detect auth mechanisms? [y/N]: y ← y入力 Trying to detect supported methods (SMTP)... Testing none: SUPPORTED Testing login: SUPPORTED Testing plain: SUPPORTED Testing CRAM-MD5: NOT SUPPORTED Testing DIGEST-MD5: NOT SUPPORTED What authentication mechanism do you want to use for SMTP connections? none - Your SMTP server does not require authorization. login - Plaintext. If you can do better, you probably should. plain - Plaintext. If you can do better, you probably should. cram-md5 - Slightly better than plaintext. digest-md5 - Privacy protection - better than cram-md5. *** YOUR SMTP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE *** If you don't understand or are unsure, you probably want "none" none, login, plain, cram-md5, or digest-md5 [none]: login ← login入力 SMTP authentication uses IMAP username and password by default. Would you like to use other login and password for all SquirrelMail SMTP connections? [y/N]:n ← n入力 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Server Settings General ------- 1. Domain : ufuso.dip.jp 2. Invert Time : false 3. Sendmail or SMTP : SMTP SMTP Settings ------------- 4. SMTP Server : ufuso.dip.jp 5. SMTP Port : 25 6. POP before SMTP : false 7. SMTP Authentication : login (with IMAP username and password) 8. Secure SMTP (TLS) : false 9. Header encryption key : A. Update IMAP Settings : ufuso.dip.jp:143 (dovecot) H. Hide SMTP Settings R Return to Main Menu C Turn color off 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 off S Save data Q Quit Command >> 10 ← Languages選択 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 off S Save data Q Quit Command >> 1 ← Default Language選択 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 off S Save data Q Quit Command >> 2 ← Default 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 ← iso-2022-jp入力 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 R Return to Main Menu C Turn color off 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 off S Save data Q Quit Command >> 4 ← General Options選択 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- General Options 1. Data Directory : /var/lib/squirrelmail/prefs/ 2. Attachment Directory : /var/spool/squirrelmail/attach/ 3. Directory Hash Level : 0 4. Default Left Size : 150 5. Usernames in Lowercase : false 6. Allow use of priority : true 7. Hide SM attributions : false 8. Allow use of receipts : true 9. Allow editing of identity : true Allow editing of name : true Remove username from header : false 10. Allow server thread sort : true 11. Allow server-side sorting : true 12. Allow server charset search : true 13. Enable UID support : true 14. PHP session name : SQMSESSID 15. Location base : 16. Only secure cookies if poss. : true 17. Disable secure forms : false 18. Page referal requirement : R Return to Main Menu C Turn color off S Save data Q Quit Command >> 7 ← Hide SM attributions選択 Hide SM attributions (y/n) [n]: y ← y入力 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- General Options 1. Data Directory : /var/lib/squirrelmail/prefs/ 2. Attachment Directory : /var/spool/squirrelmail/attach/ 3. Directory Hash Level : 0 4. Default Left Size : 150 5. Usernames in Lowercase : false 6. Allow use of priority : true 7. Hide SM attributions : true 8. Allow use of receipts : true 9. Allow editing of identity : true Allow editing of name : true Remove username from header : false 10. Allow server thread sort : true 11. Allow server-side sorting : true 12. Allow server charset search : true 13. Enable UID support : true 14. PHP session name : SQMSESSID 15. Location base : 16. Only secure cookies if poss. : true 17. Disable secure forms : false 18. Page referal requirement : R Return to Main Menu C Turn color off 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 off S Save data Q Quit Command >> 8 ← Plugins選択 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Plugins Installed Plugins 1. delete_move_next 2. squirrelspell 3. newmail Available Plugins: 4. administrator 5. bug_report 6. calendar 7. compatibility 8. empty_trash 9. filters 10. fortune 11. info 12. listcommands 13. mail_fetch 14. message_details 15. secure_login 16. sent_subfolders 17. spamcop 18. test 19. translate R Return to Main Menu C Turn color off S Save data Q Quit Command >> 7 ← compatibility選択 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Plugins Installed Plugins 1. delete_move_next 2. squirrelspell 3. newmail 4. compatibility Available Plugins: 5. administrator 6. bug_report 7. calendar 8. empty_trash 9. filters 10. fortune 11. info 12. listcommands 13. mail_fetch 14. message_details 15. secure_login 16. sent_subfolders 17. spamcop 18. test 19. translate R Return to Main Menu C Turn color off S Save data Q Quit Command >> 8 ← empty_trash選択 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Plugins Installed Plugins 1. delete_move_next 2. squirrelspell 3. newmail 4. compatibility 5. empty_trash Available Plugins: 6. administrator 7. bug_report 8. calendar 9. filters 10. fortune 11. info 12. listcommands 13. mail_fetch 14. message_details 15. secure_login 16. sent_subfolders 17. spamcop 18. test 19. translate R Return to Main Menu C Turn color off S Save data Q Quit Command >> 15 ← secure_login選択 SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Plugins Installed Plugins 1. delete_move_next 2. squirrelspell 3. newmail 4. compatibility 5. empty_trash 6. secure_login Available Plugins: 7. administrator 8. bug_report 9. calendar 10. filters 11. fortune 12. info 13. listcommands 14. mail_fetch 15. message_details 16. sent_subfolders 17. spamcop 18. test 19. translate R Return to Main Menu C Turn color off S Save data Q Quit Command >> q ← メイン/メニューに戻る You have not saved your data. Save? [Y/n]: y ← y入力 Data saved in config.php Exiting conf.pl. You might want to test your configuration by browsing to http://your-squirrelmail-location/src/configtest.php Happy SquirrelMailing! |
■secure_loginプラグインの編集
[root@ufuso ~]# cd /usr/share/squirrelmail/plugins/secure_login ← secure_loginプラグインディレクトリへ移動 [root@ufuso secure_login]# cp config.sample.php config.php ← 設定ファイル作成 [root@ufuso secure_login]# vi config.php ← 設定ファイル編集 // if you want user sessions to remain in SSL for their entire duration, // set the following to zero: // $change_back_to_http_after_login = 0; ← 0へ変更(ログイン後もSSL通信を継続) [root@ufuso secure_login]# /etc/rc.d/init.d/httpd reload ← httpd の再起動 httpd を再読み込み中: |
■SELinuxを有効にしている場合
[root@ufuso ~]#setsebool -P httpd_can_network_connect on ← Webからの ネットワーク接続を許可 |
■root宛メールも確認出きるように転送する
[root@ufuso ~]#sed -i '/^root:/d' /etc/aliases ← 旧root宛メール転送設定削除 [root@ufuso ~]# echo "root: ufuso@gmail.com" >> /etc/aliases ← root宛メールを 他のメルアド(ufuso@gmail.comは例示)宛に転送する [root@ufuso ~]# newaliases ← 転送設定反映 [root@ufuso ~]# echo test|mail root ← テストメールをroot宛に送信する |
■動作確認
1.http://サーバー名/webmail/にアクセスして、赤枠1のようにhttps://サーバー名/webmail/が表示されることを確認します。公的認証が無いので怪しいサイトになってしまいますが、赤枠2をクリックしてログイン画面に進みます。
2.ログイン名にはCentOSのユーザー名(例示では「tu」)、パスワードにはtuのユーザーパスワードを入力します。
3.ログイン後の画面です。rootからのtestメールが受信できていることを確認してください。
■送受信確認
(1)内部メール同士(例示はxxxx@ufuso.dip.jp同士)
(2)外部から内部(xxxx@ufuso.jpからxxxx@ufuso.dip.jpへ送信)
(3)内部から外部(xxxx@ufuso.dip.jpからxxxx@ufuso.jpへ送信)
(4)内部から携帯(xxxx@ufuso.dip.jpからxxxx@ezweb.ne.jpへ送信)
※携帯電話は、通常パソコンからのメールを拒否する設定になっているので、自宅サーバーからのメールを受信する設定が携帯側で必要になる。下図は自宅サーバーからiPhone5sに送信したメールを自宅サーバーに転送させて表示したもの。
(5)携帯から内部(xxxx@ezweb.ne.jpからxxxx@ufuso.dip.jpへ送信)