トップ > Ubuntu 8.04 によるサーバーの構築 >

Dovecot (POP3サーバー) の構築

Dovecot のインストールと POP3 の利用設定

 メール受信用のサーバー(POP サーバー)を, Dovecot により構築します。

  1. 以下のコマンドを実行して, Dovecot をインストールする。
    $ sudo apt-get install dovecot-common dovecot-pop3d
  2. /etc/dovecot/dovecot.conf を以下のように作成する。
    protocols = pop3
    disable_plaintext_auth = no
    mail_privileged_group = mail
    protocol pop3 {
      pop3_uidl_format = %08Xu%08Xv
    }
    auth default {
      mechanisms = plain
      passdb pam {
      }
      userdb passwd {
      }
      user = root
    }
    dict {
    }
    plugin {
    }
  3. 以下のコマンドを実行して, Dovecot を再起動する。
    $ sudo /etc/init.d/dovecot restart
  4. クライアントのメーラーのアカウントを以下のように設定する。
    名前 テスト
    メールアドレス abc@shitomi.jp
    サーバーの種類 POP3
    受信メール(POP3) 192.168.0.1
    送信メール(SMTP) 192.168.0.1
    アカウント abc
    接続方法 LANを使用して接続する
    SMTPポート番号 25
    POP3ポート番号 110
  5. ユーザーアカウント abc を設定し, postmaster と root ( abc のエイリアス) を設定したサーバーに外部からメールを送信した結果を以下に示す。
    送信可能 abc@shitomi.jp
    abc@shitomi.net
    postmaster@shitomi.jp
    postmaster@shitomi.net
    root@shitomi.jp
    root@shitomi.net
    送信不可能 abc@aaa.shitomi.jp
    abc@aaa.shitomi.net
    abc@ns.shitomi.jp
    abc@www.shitomi.jp
    abc@db.shitomi.jp
    abc@ns.shitomi.net
    abc@www.shitomi.net
    abc@db.shitomi.net
    xyz@shitomi.jp
    xyz@shitomi.net

POP3 over SSL の利用設定

 前に設定した POP3 に加えて, POP3 over SSL が利用できるように, Dovecot の設定を変更します。

  1. root でログインする。
  2. 前に作成した秘密鍵サーバー証明書を利用して, /etc/dovecot/dovecot.conf を以下のように修正する。
    ssl_cert_file = /etc/ssl/certs/server.crt
    ssl_key_file = /etc/ssl/private/server.key


    protocols = pop3 pop3s
    disable_plaintext_auth = no
    mail_privileged_group = mail
    protocol pop3 {
      pop3_uidl_format = %08Xu%08Xv
    }
    auth default {
      mechanisms = plain
      passdb pam {
      }
      userdb passwd {
      }
      user = root
    }
    dict {
    }
    plugin {
    }
  3. 以下のコマンドを実行して, dovecot アカウントを ssl-cert グループに追加する。
    $ sudo usermod -G ssl-cert dovecot
  4. 以下のコマンドを実行して, Dovecot サーバーを再起動する。
    $ sudo /etc/init.d/dovecot restart
  5. 以下のように,メーラー (Outlook Express) のアカウント abc の詳細設定をする。
    Outlook ExpressにおけるPOP over SSLの利用設定(その1)/メール受信用サーバー/Fedora Core
  6. 警告メッセージが出るので,[はい]を選択する。
    Outlook ExpressにおけるPOP over SSLの利用設定(その2)/メール受信用サーバー/Fedora Core

自己認証局(プライベート CA )を利用した S/MIME の利用

 プライベート CA を利用して,暗号化を施した電子メールの送受信ができるようにします。なお,クライアントのメーラーには Becky! を利用します。
  1. S/MIME 機能を追加するプラグインをダウンロードする。
  2. このプラグインを,クライアントのメーラー (Becky!) に導入する。
  3. アカウント abc でログインする。
  4. 以下のコマンドを実行して,アカウント abc のサイト証明書署名要求 (csr.pem) と秘密鍵 (abc.key) を作成する。
    $ cd /tmp
    $ openssl req -new -keyout abc.key -out csr.pem
  5. 続いて,以下のように入力する。
    Generating a 1024 bit RSA private key
    .......................++++++
    ............++++++
    writing new private key to 'abc.key'
    Enter PEM pass phrase:[Passwordを入力]
    Verifying password - Enter PEM pass phrase:[Passwordを再入力]
    -----
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) [GB]:JP
    State or Province Name (full name) [Berkshire]:Miyagi
    Locality Name (eg, city) [Newbury]:Sendai
    Organization Name (eg, company) [My Company Ltd]:Self
    Organizational Unit Name (eg, section) []:[リターンキーを押す]
    Common Name (eg, your name or your server's hostname) []:abc
    Email Address []:abc@shitomi.jp

    Please enter the following 'extra' attributes
    to be sent with your certificate request
    A challenge password []:[リターンキーを押す]
    An optional company name []:[リターンキーを押す]
  6. 以下のコマンドを実行して,構築した CA のルート証明書 (ca.cer) を作成する。
    $ sudo openssl x509 -inform pem -outform der -in /usr/lib/ssl/misc/demoCA/cacert.pem -out /tmp/ca.cer
  7. root でログインする。
  8. 以下のコマンドを実行して,公開かぎ証明書 (abc.crt) を作成する。
    $ cd /usr/lib/ssl/misc
    $ sudo openssl ca -out /tmp/abc.crt -infiles /tmp/csr.pem
  9. 以下のコマンドを実行して,証明書付きの秘密かぎ (abc.p12) を作成する。
    $ openssl pkcs12 -export -inkey /tmp/abc.key -in /tmp/abc.crt -certfile /usr/lib/ssl/misc/demoCA/cacert.pem -name "abc" -out /tmp/abc.p12
  10. ルート証明書,公開かぎ証明書及び証明書付きの秘密かぎを,クライアントにインポートする。

 このサイトに書かれていることが原因でトラブルが発生しても,私は責任を取ることができません。したがいまして,ここで述べられていることに関する実行は,自己責任でお願いいたします。なお,このサイトはリンクフリーで,リンク時の連絡も不要です。

サイト内関連リンク:Postfix, Apache