差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
freebsd:freebsd_9.0-releaseでcourier_mail_serverを使う [2012-03-30 23:28] Decomo |
freebsd:freebsd_9.0-releaseでcourier_mail_serverを使う [2020-12-03 19:36] Decomo Deleted by PageMove plugin |
||
---|---|---|---|
行 1: | 行 1: | ||
- | ====== FreeBSD 9.0-RELEASEでCourier Mail Serverを使う ====== | + | ====== FreeBSD 9.0RでCourier Mail Serverを使う ====== |
===== 環境 ===== | ===== 環境 ===== | ||
行 8: | 行 8: | ||
* ユーザーの標準メールのデータは ~/ | * ユーザーの標準メールのデータは ~/ | ||
+ | ===== 本記事で出来るようになること ===== | ||
+ | * システムのメールサーバを標準のsendmailからCourier Mail Serverに置き換える。 | ||
+ | * ユーザーのメールをIMAPで読み書きする。 | ||
+ | * ユーザーのメールをIMAPsで読み書きする。 | ||
===== 用語メモ ===== | ===== 用語メモ ===== | ||
* / | * / | ||
行 20: | 行 24: | ||
sudo make install | sudo make install | ||
</ | </ | ||
- | 仮想メールボックスの利用を見据え、< | + | 仮想メールボックスの利用を見据え、'' |
単にsendmailの置き換えだけなら、特に弄らなくてもいいと思う。 | 単にsendmailの置き換えだけなら、特に弄らなくてもいいと思う。 | ||
- | インストールの最後に「Would you like to activate Courier in / | + | インストールの最後に「Would you like to activate Courier in / |
<code |h / | <code |h / | ||
行 37: | 行 41: | ||
===== 設定 ===== | ===== 設定 ===== | ||
==== Courier Mail Server全体の設定 ==== | ==== Courier Mail Server全体の設定 ==== | ||
- | < | + | '' |
ここでは変更した箇所のみを掲載する。 | ここでは変更した箇所のみを掲載する。 | ||
行 51: | 行 55: | ||
* 今後作る予定がある | * 今後作る予定がある | ||
- | 場合は< | + | 場合は'' |
=== authlibの設定 === | === authlibの設定 === | ||
- | portのインストールオプションで追加の< | + | portのインストールオプションで追加の'' |
<code |h / | <code |h / | ||
行 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になってしまうので注意)。 | ||
- | {{: | + | {{ : |
+ | |||
+ | ==== aliasesの編集 ==== | ||
+ | 良い子の皆は、root宛のメール転送先を既に適切に設定していると思うが、俺は設定を忘れていたのでここで設定しておく。 | ||
+ | |||
+ | <code |h / | ||
+ | root: | ||
+ | </ | ||
+ | |||
+ | エイリアスデータベースを更新。 | ||
+ | <code bash> | ||
+ | sudo newaliases | ||
+ | </ | ||
===== IMAPを使えるようにする ===== | ===== IMAPを使えるようにする ===== | ||
- | < | + | '' |
<code |h / | <code |h / | ||
- | ADDRESS=192.168.xxx.yyy | ||
IMAPDSTART=YES | IMAPDSTART=YES | ||
MAILDIRPATH=Library/ | MAILDIRPATH=Library/ | ||
行 142: | 行 157: | ||
Thunderbirdで接続してみる。 | 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を許容するなら、'' |