差分
このページの2つのバージョン間の差分を表示します。
次のリビジョン | 前のリビジョン 次のリビジョン 両方とも次のリビジョン | ||
freebsd:freebsd_9.0-releaseでcourier_mail_serverを使う [2012-03-30 23:02] Decomo 作成 |
freebsd:freebsd_9.0-releaseでcourier_mail_serverを使う [2014-12-31 23:01] Decomo |
||
---|---|---|---|
行 1: | 行 1: | ||
- | ====== FreeBSD 9.0-RELEASEでCourier Mail Serverを使う ====== | + | ====== FreeBSD 9.0RでCourier Mail Serverを使う ====== |
===== 環境 ===== | ===== 環境 ===== | ||
行 8: | 行 8: | ||
* ユーザーの標準メールのデータは ~/ | * ユーザーの標準メールのデータは ~/ | ||
+ | ===== 本記事で出来るようになること ===== | ||
+ | * システムのメールサーバを標準のsendmailからCourier Mail Serverに置き換える。 | ||
+ | * ユーザーのメールをIMAPで読み書きする。 | ||
+ | * ユーザーのメールをIMAPsで読み書きする。 | ||
===== 用語メモ ===== | ===== 用語メモ ===== | ||
* / | * / | ||
行 69: | 行 73: | ||
</ | </ | ||
- | 新規ユーザー用に< | + | 新規ユーザー用に< |
<code bash> | <code bash> | ||
- | cd /etc/share/skel | + | cd /usr/share/skel |
sudo mkdir -p Library/ | sudo mkdir -p Library/ | ||
sudo maildirmake Library/ | sudo maildirmake Library/ | ||
行 130: | 行 134: | ||
muttで受信出来たか確認(mailコマンドはMaildirに対応しておらず、No mailになってしまうので注意)。 | muttで受信出来たか確認(mailコマンドはMaildirに対応しておらず、No mailになってしまうので注意)。 | ||
- | {{: | + | {{ :pc:freebsd: |
+ | |||
+ | ==== aliasesの編集 ==== | ||
+ | 良い子の皆は、root宛のメール転送先を既に適切に設定していると思うが、俺は設定を忘れていたのでここで設定しておく。 | ||
+ | |||
+ | <code |h / | ||
+ | root: | ||
+ | </ | ||
+ | |||
+ | エイリアスデータベースを更新。 | ||
+ | <code bash> | ||
+ | sudo newaliases | ||
+ | </ | ||
+ | |||
+ | ===== IMAPを使えるようにする ===== | ||
+ | < | ||
+ | <code |h / | ||
+ | IMAPDSTART=YES | ||
+ | MAILDIRPATH=Library/ | ||
+ | </ | ||
+ | IPアドレスはNICに割り当てられているアドレスそのものを指定しないと、外部からのIMAP接続要求をListen出来ないので要注意。 | ||
+ | |||
+ | Thunderbirdで接続してみる。 | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | Courier Mail ServerのIMAPはINBOXをルート名前空間とするので、デフォルトでは送信済みトレイやゴミ箱が受信トレイにぶら下がる形となる。 | ||
+ | |||
+ | 「アカウントの設定> | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | |||
+ | |||
+ | ==== IMAP over SSL(IMAPs)を使うようにする ==== | ||
+ | 単なるIMAPだと、パスワード・メール本文ともに平文で通信路を流れ、非常に宜しくないのでIMAPsを使うようにする。 | ||
+ | |||
+ | === 秘密鍵の生成 === | ||
+ | <code bash> | ||
+ | # openssl genrsa -aes256 2048 > imapd.key | ||
+ | Generating RSA private key, 2048 bit long modulus | ||
+ | ..........................................................................+++ | ||
+ | ......................................................+++ | ||
+ | e is 65537 (0x10001) | ||
+ | Enter pass phrase: | ||
+ | Verifying - Enter pass phrase: | ||
+ | </ | ||
+ | |||
+ | === 証明書署名要求の生成 === | ||
+ | <code bash> | ||
+ | # openssl req -new -key imapd.key > imapd.csr | ||
+ | Enter pass phrase for imapd.key: | ||
+ | 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 ' | ||
+ | ----- | ||
+ | Country Name (2 letter code) [AU]:JP | ||
+ | State or Province Name (full name) [Some-State]: | ||
+ | Locality Name (eg, city) []: | ||
+ | Organization Name (eg, company) [Internet Widgits Pty Ltd]: | ||
+ | Organizational Unit Name (eg, section) []:CA | ||
+ | Common Name (eg, YOUR name) []: | ||
+ | Email Address []: | ||
+ | |||
+ | Please enter the following ' | ||
+ | to be sent with your certificate request | ||
+ | A challenge password []: | ||
+ | An optional company name []: | ||
+ | </ | ||
+ | |||
+ | === 自己証明書の生成 === | ||
+ | <cli prompt="# | ||
+ | # openssl x509 -in imapd.csr -days 3650 -req -signkey imapd.key > imapd.crt | ||
+ | Signature ok | ||
+ | subject=/ | ||
+ | Getting Private key | ||
+ | Enter pass phrase for imapd.key: | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | === 秘密鍵のパスワードを解除 === | ||
+ | パスワードが掛かったままだとCourier Mail Server起動時に、入力を要求されるので予め解除する。 | ||
+ | <code bash> | ||
+ | sudo mv imapd.key imapd.pass.key | ||
+ | sudo openssl rsa -in imapd.pass.key -out imapd.key | ||
+ | </ | ||
+ | |||
+ | === 秘密鍵と証明書の結合 === | ||
+ | Courier Mail Serverでは秘密鍵と証明書を結合したファイルを使う。ついでにSSL関連ファイルのパーミッションを落とす(特に秘密鍵は取り扱いに注意すること)。 | ||
+ | |||
+ | <code bash> | ||
+ | cat imapd.key imapd.crt > imapd.pem | ||
+ | chmod 400 imapd.key | ||
+ | chmod 400 imapd.csr | ||
+ | chmod 400 imapd.crt | ||
+ | chmod 400 imapd.pem | ||
+ | </ | ||
+ | |||
+ | === サーバの設定 === | ||
+ | < | ||
+ | <code |h / | ||
+ | IMAPDSSLSTART=YES | ||
+ | IMAPDSTARTTLS=YES | ||
+ | IMAP_TLS_REQUIRED=1 | ||
+ | TLS_CERTFILE=/ | ||
+ | MAILDIRPATH=Library/ | ||
+ | </ | ||
+ | |||
+ | 生のIMAPを許容するなら、< |