Postfix でメールリレーの設定 (SMTP クライアント + SMTP Auth)

提供:maruko2 Note.
移動: 案内, 検索

目次

メールリレーの設定

ローカルメール以外をリレーさせる設定。

main.cf

relayhost = [mail2.example.com]
relayhost = [mail.example.com]

[hostname] のように、転送先ホスト名を [ ] で囲むと MX検索をしなくなる。[1]

複数行指定した場合、下の行が優先される。

特定のドメインごとにリレー先を変えるには、transport で設定する。Postfix manual - transport(5)

main.cf

transport_maps = hash:/etc/postfix/transport

transport テーブルの例

example.com    :
foo.com        smtp:[mail.foo.com]
bar.co.jp      smtp:[mx.bar.co.jp]
*              smtp:10.20.30.40

transport テーブル編集後は、ハッシュ化すること。

[shell]# postmap /etc/postfix/transport

Postfix を SMTP Auth 対応の SMTP クライアントとして動作させメールをリレーする

SMTP Auth (SMTP認証) が必要なサーバにリレーする場合、Postfix SMTP クライアントの SASL 認証機能を有効にすることで SMTP Auth に対応することができる。

main.cf の設定

relayhost = [mail.example.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/relay_password
smtp_sasl_security_options = noanonymous
relayhost
ローカルメール以外を送るメールサーバを指定する。
smtp_sasl_auth_enable
SMTP Auth 認証を有効にする。
smtp_sasl_password_maps
SMTP クライアント検索テーブルを指定する。

smtp_sasl_password_maps で指定する検索データベースファイル名は .db の拡張子を付けない。

smtp_sasl_security_options
デフォルト: noplaintext, noanonymous
Postfix SMTP クライアントで使用する認証メカニズム。
  • noplaintext
平文パスワードを使う認証方法を許可しません。
  • noactive
active (非辞書) 攻撃を受けるような方法を許可しません。
  • nodictionary
passive (辞書) 攻撃を受けるような方法を許可しません。
  • noanonymous
匿名ログインを許可しません。
  • mutual_auth
相互認証を提供する方法のみを許可します (SASL バージョン 1 では使えません)。

smtp_sasl_password_maps(SMTP クライアント検索テーブル)

1. リレー先サーバのアドレスと、認証で使用するユーザ名とパスワードを記述したファイル /etc/postfix/relay_password を作成する。

/etc/postfix/relay_password の内容

submission ポートの SMTP サーバへリレーするときは、アドレスの最後に :587 とポート番号を指定する。

mail.example.com            username:password
submission.example.org:587  username:password

2. postmap コマンドを使用し、パスワードファイルから検索データベースを作成する。

[shell]# postmap hash:/etc/postfix/relay_password

実行後、/etc/postfix/relay_password.db データベースファイルが作成される。

3. postfix を再読み込みし、設定を反映させる。

[shell]# /etc/init.d/postfix reload

参考ページ

脚注

  1. Postfix設定パラメーター relayhost
このエントリーをはてなブックマークに追加
個人用ツール
名前空間
変種
表示
操作
案内
ツールボックス

注目のページ

このサイトのはてなブックマーク数