31:メールサーバーの設定:postfix

参考URL:http://e-garakuta.net/techinfo/doku.php/linux/postfix-virtual
今まではlocalのメールはaliasesでkinryokai.netに転送出来ていましたが。localメールもvirtualを使用するようにしたので、転送出来なくなりますので、localのメールはISPのメアドに転送するようにします。
私はメールソフトはthunderbirdを使用しておりますので、フィルターの設定で、そのサーバー用のディレクトリーを設定していますので問題はありません。
# gedit /etc/aliases

前略
root: ISPのメアド

# newaliases
次にvirtual専用のユーザーを作ります
# groupadd -g 10000 vuser
# useradd -g vuser -u 10000 -s /sbin/nologin vuser
*postfixの設定ファイルの編集(抜粋)
# gedit /etc/postfix/main.cf

変更箇所のみ
myhostname = mail.kinryokai.net ← 自分のホスト名
mydomain = kinryokai.net ← 自分のドメイン
myorigin = $mydomain ← 変更
inet_interfaces = all ← 変更
inet_protocols = ipv4 ← ipv4しか扱わない
mydestination = ← 右辺は必ずブランク
home_mailbox = Maildir/ ← #を取り有効化
header_checks = regexp:/etc/postfix/header_checks ← #を取り有効化
smtpd_banner = $myhostname ESMTP unknown ← #を取り右辺変更
#ここから下を追記
message_size_limit = 52428800
mailbox_size_limit = 9663676416
virtual_mailbox_limit = 9663676416

disable_vrfy_command = yes
smtpd_helo_required = yes
smtpd_sender_restrictions = reject_unknown_sender_domain

# Virtual Domains with MySQL
#local_transport = local
local_transport = virtual
#virtual_transport = virtual :デフォルト見たい
virtual_mailbox_base = /Mail
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
#virtual_alias_domains = $virtual_alias_maps :デフォルト見たい
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_minimum_uid = 10000
virtual_uid_maps = static:10000
virtual_gid_maps = static:10000

# SMTP AUTH
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_local_domain = $myhostname
smtpd_client_restrictions =
    permit_mynetworks,
    reject_non_fqdn_sender,
    reject_non_fqdn_recipient,
    reject_unknown_client,
    reject_rbl_client all.rbl.jp,
#    reject_rbl_client zen.spamhaus.org,
#    reject_rbl_client bl.spamcop.net,
    check_client_access hash:/etc/postfix/access,
    permit
smtpd_recipient_restrictions = 
    permit_mynetworks,
    permit_sasl_authenticated,
    permit_auth_destination,
    reject_unauth_destination,
    reject

# SMTPS
#smtpd_use_tls = yes
#smtpd_tls_cert_file = /etc/pki/tls/certs/mail.pem
#smtpd_tls_key_file = /etc/pki/tls/certs/mail.pem
#smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_scache

SMTPSは全部コメントアウトしていますが、テスト後有効にするために記入して置きます。reject_rbl_clientはあまり多くすると遅くなるので、様子を見ながら有効化します。
smtpd_client_restrictions=に check_client_access hash:/etc/postfix/access,がありますが、デフォルトでは全てコメントアウトして存在しています。書式は文中に記入がありますが
IPアドレス REJECT で拒否するIP
IPアドレス OK でアクセプトするIPです。
又、IPを 1.2.3 のように記入すればIPレンジになります。
運用後に設定すればいいでしょう。

 *mysql関連の三つのファイルを作成
# gedit /etc/postfix/mysql_virtual_alias_maps.cf

user = postfix
password = xxxxxxx
hosts = localhost
dbname = postfix
table = alias
select_field = goto
where_field = address

# gedit /etc/postfix/mysql_virtual_domains_maps.cf

user = postfix
password = xxxxxxx
hosts = localhost
dbname = postfix
table = domain
select_field = domain
where_field = domain
additional_conditions = and active = '1'

# gedit /etc/postfix/mysql_virtual_mailbox_maps.cf

user = postfix
password = xxxxxxx
hosts = localhost
dbname = postfix
table = mailbox
select_field = maildir
where_field = username

header_checksの編集
# gedit /etc/postfix/header_checks

/^From:.*<#.*@.*>/ REJECT
/^Return-Path:.*<#.*@.*>/ REJECT

を最後にでも追記
main.cfに check_client_access hash:/etc/postfix/access, と設定しているので、そのDBを作ります。
# postmap /etc/postfix/access
このアクセスリストの記入方法はhttp://www.postfix-jp.info/trans-2.2/jhtml/access.5.htmlに説明があります。自分でこのリストを変更したら、必ず上記のコマンドでDBを更新して置きます。
次はdovecotの設定です

フジマル について

1947年生れ、東京電機大学二部電気通信工学科卒、最後はスリランカ航空で営業だったのですが2018年に㈱インパック・ジャパンに再就職。趣味:登山、スキー、車いじり、コンピューター
カテゴリー: 省エネサーバー製作(CentOS 6) パーマリンク

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA


このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください