2011/02/03(木)Debian 5.0 で Postfix の設定メモ

インストール

# apt-get install postfix dovecot-pop3d

dovecotも使うので入れますが、この記事では解説しません。

設定

Maildir形式に設定

# メールのFQDN
myhostname = xxxx.dom
# 受信するドメインの一覧
mydestination =
  example.net,
  example.dom,
  localhost
relayhost =

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
append_at_myorigin = yes
# コメントアウト(ここが有効だとMaildirにならない)
#mailbox_command = /usr/bin/procmail -a "$EXTENSION"

mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
recipient_delimiter = +
inet_interfaces = all

# セキュリティ用のVersion等を隠す
smtpd_banner = ESMTP unknow
# メールdirに
home_mailbox = Maildir/
# メールボックスを無制限に
message_size_limit = 16777216
mailbox_size_limit = 0

バーチャルドメイン

複数のドメインがあるとき、ドメインごとに受信ユーザーを変更することができます。

main.cfの設定

virtual_alias_maps = hash:/etc/postfix/virtual

/etc/postfix/virtualの作成

foo@example.com		bar
foo@example.net		xxx@other.dom

ここからデータベースを生成します。

# postmap /etc/postfix/virtual

"portmap"ではなく"postmap"であることに注意してください。これは、sendmailにおける以下のコマンドとほぼ同じ意味です。

# cd /etc/postfix
# makemap hash virtual<virtual

/etc/postfix/virtual.dbが無事生成されたら再起動してください。/etc/aliasesと同様に、これらのファイル更新時は再起動は必要ありません。*1

virtualの生成コマンドを忘れそうなら、Makefileを置いておくのも手です。

# Makefile
virtual.db: virtual
  postmap virtual

*1 : .dbファイルの再生成は必要です。

SMTP Authとmutt