ページ

2010年12月5日日曜日

Postfix 設定手順のまとめ(OP25B対策)

Postfix 設定手順のまとめ

最近の国内プロバイダがOP25B (Outbound Port 25 Blocking) を利用するようになって
以降、プロバイダ外部への25番ポートへの接続を禁止するようになっているケースが多い。
これは、プロバイダのsmtpサーバの利用を許可するが、
送信アドレスはプロバイダの自ドメインに限るというものです。

当方ではフリーのダイナミックDNSに登録しており、
自宅用のメールアドレスを利用して外部メール(Gmailなどに)に送信したいのですが、
プロバイダから指定されたアドレスと異なる為に、

connect to gmail-smtp-in.l.google.com[74.125.53.27]

というような送信エラーとなってしまいます。

そこで、利用しているプロバイダの自ドメインを踏み台にして
外部メールに送受信する方法をメモしておく事にします。


※環境
CentOS 5.3
Postfix

【送信側の設定】

今インストールされているMTAを確認する。
# alternatives --display mta

postfixnのインストール
# yum install -y postfix

postfixの設定
# vi /etc/postfix/main.cf

-----------------------------------
#ホスト名を設定する。
myhostname = ise-web.com
#外部からのメール受信を許可
inet_interfaces = all
#メールサーバのネットワーク
mynetworks = 192.168.11.0/24
#メールボックス形式をMaildir形式にする
home_mailbox = Maildir/
#メールサーバーソフト名の隠蔽化
smtpd_banner = $myhostname ESMTP unknown

#以下文末に追加
#受信メールサイズ制限
message_size_limit = 10485760

#OP25B対策
relayhost = <プロバイダのSMTPサーバー>:587

#SMTP-Auth設定
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/authinfo
smtp_sasl_security_options = noanonymous
smtp_sasl_mechanism_filter = login, plain
-----------------------------------

プロバイダのSMTPサーバーに接続する為の情報を設定する。
vi /etc/postfix/authinfo
-----------------------------------
<プロバイダのSMTPサーバー> <プロバイダのメールアカウント>:<プロバイダのメールパスワード>
-----------------------------------

# chmod 640 /etc/postfix/authinfo
# postmap /etc/postfix/authinfo
# /etc/rc.d/init.d/postfix reload

SMTP-Auth設定
# /etc/rc.d/init.d/saslauthd start
# chkconfig saslauthd on
# chkconfig --list saslauthd

sendmailの停止
# /etc/rc.d/init.d/sendmail stop

メールサーバの切替え
alternatives --config mta

postfix起動
# /etc/rc.d/init.d/postfix start
# chkconfig postfix on
# chkconfig --list postfix


"fatal: no SASL authentication mechanisms"と表示される場合は必要なライブラリが不足しているので下記をインストールする。
yum -y install cyrus*


【受信側の設定】

Dovecotのインストール
# yum install -y dovecot

Dovecot設定
# vi /etc/dovecot.conf

# 以下の記述を追記
protocols = imap imaps pop3 pop3s
mail_location = maildir:~/Maildir

Dovecot起動
# /etc/rc.d/init.d/dovecot start
# chkconfig dovecot on
# chkconfig --list dovecot

0 件のコメント:

コメントを投稿