|
CentOSを使っているのですが、標準のSMTPは『sendmail』ですね。
# yum list installed | grep sendmail
sendmail.x86_64 8.13.8-2.el5 installed
sendmail-cf.x86_64 8.13.8-2.el5 installed
# yum list installed | grep postfix
(何も出ません)
セキュリティ&設定の面で有利なので、『sendmail』から『postfix』へ切り替えてみましょう。
『sendmail』サービス停止
# /etc/init.d/sendmail stop
sm-client を停止中: [OK]
sendmail を停止中: [OK]
スタートさせない設定にしておきます。
# chkconfig sendmail off
# chkconfig --list | grep send
sendmail 0:off 1:off 2:off 3:off 4:off 5:off 6:off
『postfix』インストール
# yum install postfix
/etc/postfix に色々ファイルが入っているのが確認できます。
『sendmail』から『postfix』への切り替え
普段使うメールサーバを『sendmail』から『postfix』への切り替えます。
# alternatives --config mta
2 プログラムがあり 'mta' を提供します。
選択 コマンド
------------------------------------------- *+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix
Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:2
『postfix』に切り替わったか確認
# alternatives --config mta
2 プログラムがあり 'mta' を提供します。
選択 コマンド
------------------------------------------- * 1 /usr/sbin/sendmail.sendmail
+ 2 /usr/sbin/sendmail.postfix
Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:
[+]がpostfix側に移動しているのが確認できます。
設定ファイルの編集
main.cfを編集します。
項目的には
『inet_interfacesをallにする』
『mydestinationに受け入れるドメイン追加』
『mynetworksは許可するSMTPクライアント』
ですね。
編集結果は以下参照。
# diff main.cf main.cf.backup
< inet_interfaces = all
> #inet_interfaces = all
< #inet_interfaces = localhost
> inet_interfaces = localhost
< mydestination = $myhostname, localhost.$mydomain, localhost, e-onlineservice.com
> mydestination = $myhostname, localhost.$mydomain, localhost
< mynetworks = 192.168.1.0/24, 127.0.0.0/8
『mynetworks』『mydestination』の指定以外からはメール中継しないので、これで不正中継は防げています(後は、送信時のSMTP-Authで認証させればスパム対策はOKです:後述)。
『postfix』の起動
# /etc/init.d/postfix start
postfix を起動中:[OK]
# chkconfig postfix on
# chkconfig --list postfix
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
『sendmail』のアンインストール
# yum remove sendmail
後は、POPサーバ設定と同じ様に、Maildir形式にする設定等をする必要があります。
メールアカウントを追加した場合は、
/etc/postfix/virtual ファイルに対応を書き、
# postmap virtual
を実行。
SMTP-Auth
それから、前述のスパムメール対策をする必要があります(SMTP-Authですね)。
まずは、ポート番号(通常25番)に587番も追加。
/etc/postfix/master.cf
を編集。
smtp inet n - n - - smtpd
submission inet n - n - - smtpd
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
と、submissionの方を有効にしたら、postfix reload 。
『smtpd_sasl_auth_enable』『permit_sasl_authenticated』で、SMTP-Authも有効になってます。
認証サービスをスタート。
# /etc/init.d/saslauthd start
初期状態もONにしておきます。
# chkconfig saslauthd on
サーバ準備が出来たので、メールクライアントで送信できるかチェックします。
[ツール]-[アカウント]-[プロパティ]の変更2箇所。
『サーバー』に、送信メールサーバーの『このサーバーは認証が必要』があるので、チェック。
『詳細設定』に、ポート番号設定があるので、『25』から『587』に変更。
これで送信できれば、OKです。
…が、実はココまでだと、外部から繋げた場合のメール送信が出来ません(ローカル内からの送信は出来ます)。
結局、main.cf の mynetworks 外からは、弾かれるという事です(『554.5.7.1 Relay access denied』というエラーメッセージが出ます)。
外部から繋げてのメール送信が出来ないなんて、『OP25B』の為にSMTP-Authを用意した意味が無いですよね。
この解決は、同じmain.cf内に、SMTP-Authの記述をしてあげるとOKです。
=====
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
=====
postfix を reload して、送信できるかチェックしましょう。
※ 『Linux』に繋がる関連物を 視覚的に探しだせるサイトを作ってみました(よろしければクリックしてみてくださいね)。
リンク元:
(1) : http://www.google.co.jp/search?q=554.5.7.1+relay+access+denied&hl=ja&rlz=1T4GGLL_ja&lr=lang_ja&sa=X&ei=_jKGTJniCovCvQODk-GMBA&ved=0CBQQuAE
ページ閲覧者数:5人
[ Linux ] 一覧へ
|