ども。鉄王です。
今回のインストール、ブログのネタには事欠きません(笑)。今日は、Postfixの設定編。cronの結果をメールで飛ばすためだけに構築するので(つまり、送信専用ということですね)、検索でここに来た方のご期待に添える情報ではないかもしれませんが。
設定にあたっての与件はこんな感じ。
- LANでつながっているクライアントPCのMTAとしては使わない(クライアントPCは、契約プロバイダ〔@nifty〕のSMTPサーバを使用)
- 自ドメインあてのメール(例:root@tecking.org → hoge@tecking.org)であっても、契約プロバイダのSMTPサーバを使う
できた main.cf はこれ。なぜか /etc/postfix/ の中に main.cf がなかったので、ブクマしておいたサイトを参考にポチポチと書いていきました。
mynetworks = 127.0.0.1 inet_interfaces = all alias_maps = hash:/etc/aliases mydomain = tecking.org myhostname = hostname.tecking.org myorigin = $mydomain mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain relay_domains = $mydestination relayhost = [smtp.nifty.com]:587 transport_maps = hash:/etc/postfix/transport smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/isp_passwd smtp_sasl_security_options = noanonymous smtp_sasl_mechanism_filter = plain, login, cram-md5 message_size_limit = 0
で、/etc/postfix/transport の内容がこれ。
tecking.org smtp:smtp.nifty.com .tecking.org smtp:smtp.nifty.com
そして /etc/postfix/isp_passwd 。
smtp.nifty.com userid:password
main.cf の relayhost 項が [smtp.nifty.com]:587 になっているのはOP25B対策です。
設定にあたっては、以下のサイトの情報がたいへん参考になりました。THX!
Postfix チュートリアル
http://www.tmtm.org/postfix/tutorial/index.html
Postfix 基本設定
http://www.postfix-jp.info/trans-2.2/jhtml/BASIC_CONFIGURATION_README.html
Postfixで携帯宛のメール送信が非常に遅延したり送れないことがある。
http://www.aconus.com/~oyaji/faq/postfix_faq3.htm
OP25B対策(Outbound Port25 Blocking対策)
http://www.aconus.com/~oyaji/mail2/op25b.htm
PostfixのSMTP-AUTH設定にハマる – flairDays – てさぐりの日々
http://d.hatena.ne.jp/takaxi/20080129/1201565854
2007-10-11 – ここのことはなかったことにするかも
http://d.hatena.ne.jp/yellow_73/20071011
[2011.2.18追記]
その後にマシンを替え、Ubuntuも 8.04 Server Edition に変えて長らく運用していましたが、上記のような設定だと root 宛のメールが外部に送れないことが判明しました(気づくの遅すぎ)。たとえ /etc/aliases でrootを外部のメアドに設定してもNGです。
ということで改めて main.cf をこのように書き換えました。
mynetworks = 127.0.0.1 inet_interfaces = localhost alias_maps = hash:/etc/aliases mydomain = tecking.org myhostname = hostname.tecking.org myorigin = $mydomain mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain relay_domains = $mydestination mynetworks_style = host relayhost = [smtp.nifty.com]:25 smtp_sasl_aush_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/isp_passwd smtp_sasl_security_options = noanonymous smtp_sasl_mechanism_filter = plain, login, cram-md5