Home > linux > postfix Archive
postfix Archive
Courier-IMAPを使ったImap over SSLの設定
Courier-IMAPを使ったImap over SSLの設定方法
すでにCourier-imapをインストール済みとして説明をします。
まず設定ファイルの編集です。デフォルトでインストールをすると/usr/lib/courier-imap/etcにimapd.cnfファイルがあるので編集をします。
# vi /usr/lib/courier-imap/etc/imapd.cnf
RANDFILE = /usr/lib/courier-imap/share/imapd.rand
[ req ]
default_bits = 1024
encrypt_key = yes
distinguished_name = req_dn
x509_extensions = cert_type
prompt = no
[ req_dn ]
C=JP←国
ST=Tokyo ←県名
L=shinagawa-ku ←区・市
O=imap Mail Server←組織
OU=Automatically-generated IMAP SSL key←部署名
CN=mail.sample.jp←サーバのホスト名
emailAddress=postmaster@sample.jp←連絡先メールアドレス
[ cert_type ]
nsCertType = server
次にmkimapdcertコマンドを使って証明書を作ります。
# /usr/lib/courier-imap/share/mkimapdcert
Generating a 1024 bit RSA private key
.................++++++
...................................++++++
writing new private key to '/usr/lib/courier-imap/share/imapd.pem'
-----
1024 semi-random bytes loaded
Generating DH parameters, 512 bit long safe prime, generator 2
This is going to take a long time
......................+..........................................+...+..+....+......................................+...........................
...........+.................+................+......+.............+......................
.+................+.....................++*++*++*++*++*++*
subject= /C=JP/ST=Tokyo/L=shinagawa-ku/O=imap Mail Server/OU=Automatically-generated IMAP SSL key/CN=mail.papanda.jp/emailAddress=postmaster@papanda.jp
notBefore=Jan 25 15:20:15 2007 GMT
notAfter=Jan 25 15:20:15 2008 GMT
MD5 Fingerprint=6E:97:EA:41:04:1B:D0:BA:DD:F8:C3:82:1D:AC:9C:E2
/usr/lib/courier-imap/shareの下に証明書ファイルimapd.pemができます。
#/usr/lib/courier-imap/libexec/imapd-ssl.rc startで実行となります
- Comments (Close): 0
- TrackBacks: 0
Postfixでセキュアなメールサーバ環境の構築 【その1】
- 2004年6月12日 00:00
- postfix
Postfixの設定とSMTP_AUTHの実装。
以前、当メールサーバはQmailで構築をしていましたが、私自身、最初にサーバ構築をしたもので、中がごちゃごちゃとしており不具合もボツボツと出始めてきたので、再構築となりました。
今回もQmailとウイルスメールをメールゲートウェイで叩くためにAntiVir MailGateの導入を検証をしていたのですが私のスキル不足もあり断念いたしました。^^;
この為、上記と同じ条件でメールサーバを構築を考えていたところ、Postfix + AntiVir MailGateの組み合わせが数多くHP上に掲載されていたため、こちらを採用いたしました。
なお、今回の設定はFedora2を使っておこないました。
今回メールサーバの構築にあたって、下記ソフトを使いました。
・Postfix (Fedora2/yumによるインストール)
・AntiVir MailGate http://www.hbedv.com/
・Courier-imap http://www.inter7.com/courierimap.html
・SMTP-Auth(Postfixの設定で実現)
まずPostfixをyumコマンドを使ってインストールします。
# yum install postfix
インストールするか確認のメッセージがあるので yを押します。
次に/etc/postfix/main.cfを編集します。( 編集箇所のみ記述してます)
# vi /etc/postfix/main.cf
↓下記からmain.cfの内容
#myhostname = virtual.domain.tld
myhostname = mail.papanda.jp ← ホスト名.ドメイン名を指定
#mydomain = domain.tld
mydomain = papnda.jp ← 追加(ドメイン名を指定)
#myorigin = $mydomain ← コメント削除
↓
myorigin = $mydomain
※発信元のアドレスの形式を定義。この場合はtest@papanda.jpとなります。
#inet_interfaces = all ← コメント削除
↓
inet_interfaces = all
inet_interfaces = localhost
↓
#inet_interfaces = localhost ← コメントアウト
mydestination = $myhostname, localhost.$mydomain
↓
#mydestination = $myhostname, localhost.$mydomain ← コメントアウト
#mydestination = $myhostname, localhost.$mydomain $mydomain ← コメント削除
↓
mydestination = $myhostname, localhost.$mydomain $mydomain
※ローカルに配信するドメイン部分を指定します。上記の設定では、test@mail.papanda.jp / test@localhost.papanda.jp
/ test@papanda.jp宛てのメールアドレスを受け取ります。
#mynetworks_style = subnet ← コメント削除
↓
mynetworks_style = subnet
#mynetworks = 168.100.189.0/28, 127.0.0.0/8
mynetworks = 192.168.0.0/24, 127.0.0.0/8 ← 追加
※メール中継を許可するネットワークを設定します。上記の設定では192.168.0.0?192.168.0.255まで中継許可をします。
#relay_domains = $mydestination ← コメント解除
↓
relay_domains = $mydestination
※リレーを許可するドメインを指定します。
#home_mailbox = Maildir/ ← コメント解除
↓
home_mailbox = Maildir/
※Maildir形式を指定します。
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks
permit_sasl_authenticated
reject_unauth_destination
SMTP_AUTHの設定です。
次にroot宛てのメールを指定する一般ユーザに転送する設定をします。sendmailのaliasファイルをコピーしてそのファイルを編集します。
#cp /etc/aliases /etc/postfix/aliases
#vi /etc/postfix/aliases
root: user ←転送するユーザー
# postalias /etc/postfix/aliases ← 転送先の設定を反映します。
SMTP_AUTHの認証設定をおこないます。ここでは、システムアカウントを利用した認証の設定を行います。
# vi /usr/lib/sasl2/smtpd.conf ← smtpd.confを編集します。
pwcheck_method: saslauthd
mech_list: plain login
入力して保存します。
認証は。/etc/shadowを認証データを使いますので、以下のようにsaslauthdを起動しておきます。
# saslauthd -a shadow
最後にPostfixの起動を行います。
/etc/rc.d/init.d/sendmail stop ← 起動しているsendmailを停止します。
/usr/sbin/alternatives --config mta ← MTAをPostfixに変更します。
/etc/rc.d/init.d/postfix start ← Postfix起動
以上でPostfixの設定は完了ですが、SMTP(送信)の設定だけでPOP3/IMAP4(受信)の設定は出来ていません。
次ページでは POP3/IMAP4(受信)の設定を行います。
- Comments (Close): 0
- TrackBacks: 0
Postfixでセキュアなメールサーバ環境の構築 【その2】
- 2004年6月12日 00:00
- postfix
Courier-imapでPOP3/IMAP4の設定。
IMAP4とPOP3として「Courier-imap」インストールします。
今回はシステム上のユーザをメールアカウントとして、認証には/etc/passwdのみを使う形でのインストール方法を選択しました。
ダウンロードは下記HPから行います。
・Courier-imap http://www.inter7.com/courierimap.html
解凍したのち、以下のコマンドを一般ユーザで実行してください。rootユーザで実行するとエラーが起こります。
$ ./configure --without-authmysql --without-authldap
$ make
$ make check
※RedHatやFedora Coreでエラーが出る場合は --whith-redhatをつけるとうまくいく場合があります。
次に以下のコマンドをrootユーザで作業します。
# make install
# make install-configure
これでインストールは完了しました。/usr/lib/courier-imap/libexec/に設定ファイルが/usr/local/libexec/に実行スクリプトファイルがインストールされています。
IMAP4/POP3起動してみましょう。
IMAP起動には
#
/usr/lib/courier-imap/libexec/imapd.rc start
POP3起動には
#
/usr/lib/courier-imap/libexec/pop3d.rc start
をそれぞれ実行します。
停止をする場合はstopを指定します。
システムを再起動のさいにいちいちコマンドで起動するのはめんどくさいので自動起動の設定をします。
標準添付の起動スクリプトを/etc/rc.d の下にコピーします。
# cp /usr/lib/courier-imap/libexec/imapd.rc /etc/rc.d/rc.imapd
# cp /usr/lib/courier-imap/libexec/pop3d.rc /etc/rc.d/rc.pop3d
/etc/rc.d/rc.localに以下を追加します。
#IMAP4 Stat if [ -x /etc/rc.d/rc.imapd ]; then
echo -n "Starting IMAP/pop3 server."
/etc/rc.d/rc.imapd start
/etc/rc.d/rc.pop3d start
各ユーザのホームディレクトリにMaildirを作成します。
#su - user ← 一般ユーザーに切り替え
$ cd ~
$ /usr/lib/courier-imap/bin/maildirmake Maildir
新規ユーザ作成時に、自動的にユーザホームディレクトリにMaildirが作られるように、root で「/etc/skel」にも作成しておきます。
# /usr/lib/courier-imap/bin/maildirmake /etc/skel/Maildir
fiOutlookExpress等のIMAPサーバー対応のメーラーで動作確認して完了です。
- Comments (Close): 0
- TrackBacks: 0