Postfix でメールリレーの設定 (SMTP クライアント + SMTP Auth)
出典: maruko2 Note.
Postfix を SMTP Auth 対応の SMTP クライアントとして動作させメールをリレーするには、
- リレー先のメールサーバのアドレス
- SMTP Auth 認証で使うユーザ名とパスワード、および認証方法
を設定する必要があります。
/etc/postfix/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
- ローカルメール以外を送るメールサーバを指定する。
|
[hostname] のように、転送先ホスト名を [ ] で囲むと MX検索をしなくなります。http://www.postfix-jp.info/trans-2.3/jhtml/postconf.5.html#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 クライアント検索テーブルの作成方法
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 コマンドを使用し、パスワードファイルから検索データベースを作成する。
[root]# postmap hash:/etc/postfix/relay_password
実行後、/etc/postfix/relay_password.db データベースファイルが作成される。
3. postfix を再読み込みし、設定を反映させる。
[root]# /etc/init.d/postfix reload
参考ページ
- Postfix SASL Howto - Postfix SMTP クライアントで SASL 認証を有効にする
http://www.postfix-jp.info/trans-2.3/jhtml/SASL_README.html#client_sasl

