PostfixにSMTP Authを設定する
(CentOS3.5)Modified: 18 August 2006
CentOS3.5には、デフォルトで、Cyrus-SASLがインストールされていますので、設定のみ行えば使えます。
認証には、SASLパスワードによる方法と、UNIXアカウントで行う方式がありますが、SASLパスワードによる方法がうまくいかなかったので、UNIXアカウントで行う方式にしました。
参考になったページ
PostfixによるSMTPサーバの構築(CentOS標準版編)
http://www.aconus.com/~oyaji/centos/smtp-centos.htmCentOSにインストールされているドキュメントも参考になります。
"/usr/share/doc/postfix-2.1.x/README-Postfix-SASL-RedHat.txt"
"smtpd.conf"の変更
"/usr/lib/sasl2/smtpd.conf"以下のように追加します。
pwcheck_method: saslauthd
"saslauthd"を起動
# service saslauthd start saslauthdを起動中: [ OK ] #
"main.cf"を変更する
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $mydomain
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_destination,
permit_auth_destination,
reject"SMTP Auth"の利用を許可する。
smtpd_sasl_auth_enable = yes "anonymous"接続を拒否する。
smtpd_sasl_security_options = noanonymous OutlookExpressから利用する場合には、以下も加えます。
broken_sasl_auth_clients = yes SMTPを受け付ける条件を指定する。
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_destination,
permit_auth_destination,
reject
- permit_mynetworksは、サーバー内のネットワーク、つまり内部からの利用を許可するものです。
- permit_sasl_authenticated は、sasl認証できたものだけ受け入れる。
- reject_unauth_destination で、認証できなかったものは、拒否する。
- permit_auth_destination で、認証できたものは、受け入れる。
- reject で、その他は、拒否する。
以下の変更をしていないとうまくいきませんでした。
myorigin = $myhostname
"Postfix"を再起動します
以下のコマンドで、"Postfix"を再起動します。
# /etc/init.d/postfix restart Shutting down postfix: [ OK ] Starting postfix: [ OK ] #
ユーザの作成
以下のコマンドで、SMTP認証のためのユーザを作ります。
# /useradd tomo -s /sbin/nologin
#
パスワードデータベースの作成
以下のコマンドで、SMTP認証のための"/etc/sasldb" にパスワードデータベースが作成されます。
# /usr/sbin/saslpasswd -c tomo
Password: ******
Again (for verification): ******
#パスワードが簡単すぎる場合は、以下のメッセージが出ますので、もっと複雑にしてやり直します。
saslpasswd: generic failure 登録したユーザを確認します。
# /usr/sbin/sasldblistusers
user: tomo realm: rh73-99-postfix.tomo.ac mech: CRAM-MD5
user: tomo realm: rh73-99-postfix.tomo.ac mech: PLAIN
user: tomo realm: rh73-99-postfix.tomo.ac mech: DIGEST-MD5
#データベースのアクセス権を変更します。
# chgrp postfix /etc/sasldb
# chmod 640 /etc/sasldb
#
実際に、Beckey! で動作確認してみます。
Beckeyの設定
「ツール」メニューから「メールボックスの設定」を選択し、以下のように、「詳細」タブを選択します。
ユーザIDとパスワードは、サーバーに登録してあるアカウントです。
認証に失敗すると、以下のダイアログが出てきます。