さて、少し時間が空きましたが、postfixの設定について書いていきます。
まずは、”/etc/postfix/main.cf”から。
なお、修正したところ、コメントを外したところ、などを記述しています。
この設定をそのままコピーペーストすればいい、という性質のものではありません。
[bash]
myhostname = サーバのホスト名
mydomain = myhostnameのドメイン名のみ
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination =
mynetworks_style = host
mynetworks = $config_directory/mynetworks
relay_domains = proxy:mysql:/etc/postfix/mysql-relay_domains_maps.cf
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
recipient_delimiter = +
#
# 以下は最後にそのまま追記して下さい
#
#
#
# virtual setup
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_alias_maps.cf,
regexp:/etc/postfix/virtual_regexp
virtual_mailbox_base = /home/vmail
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains_maps.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_maps.cf
virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_limit_maps.cf
virtual_minimum_uid = 101
virtual_uid_maps = static:101
virtual_gid_maps = static:12
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
# authentication
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
broken_sasl_auth_clients = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
# tls config
smtp_use_tls = yes
smtpd_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
smtp_tls_session_cache_database = btree:$data_directory/smtp_tls_session_cache
# ssl/tlsキーを設定 ※1
smtpd_tls_key_file = /etc/httpd/conf/mail.ドメイン名.key
smtpd_tls_cert_file = /etc/httpd/conf/mail.ドメイン名.crt
# rules restrictions
smtpd_client_restrictions =
smtpd_helo_restrictions =
smtpd_sender_restrictions =
smtpd_recipient_restrictions = permit_sasl_authenticated,
permit_mynetworks,
reject_unauth_destination,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unknown_recipient_domain
# uncomment for realtime black list checks
# ,reject_rbl_client zen.spamhaus.org
# ,reject_rbl_client bl.spamcop.net
# ,reject_rbl_client dnsbl.sorbs.net
smtpd_helo_required = yes
unknown_local_recipient_reject_code = 550
disable_vrfy_command = yes
smtpd_data_restrictions = reject_unauth_pipelining
#最後にコメント外します。
#content_filter=smtp-amavis:[127.0.0.1]:10024
#
#
[/bash]
※1.
“Postfixを使ったメールサーバ構築.1/postfixadminインストールとSSL認証鍵の準備“で生成した.keyと.crtファイルを指定する
次に”/etc/postfix/master.cf”です。
こちらも同様に修正が必要な部分、追加が必要な部分のみを記述しています。
[bash]
smtp inet n – n – – smtpd
# amavisdの設定完了時にコメントを外します。
# -o content_filter=smtp-amavis:127.0.0.1:10024
# -o receive_override_options=no_address_mappings
submission inet n – n – – smtpd
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
smtps inet n – n – – smtpd
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
#
# 以下、master.cfの最後に追記
#
smtp-amavis unix – – n – 2 smtp
-o smtp_data_done_timeout=1200
-o disable_dns_lookups=yes
-o smtp_send_xforward_command=yes
127.0.0.1:10025 inet n – n – – smtpd
-o content_filter=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o smtpd_error_sleep_time=0
-o smtpd_soft_error_limit=1001
-o smtpd_hard_error_limit=1000
-o receive_override_options=no_header_body_checks
-o smtpd_bind_address=127.0.0.1
-o smtpd_helo_required=no
-o smtpd_client_restrictions=
-o smtpd_restriction_classes=
-o disable_vrfy_command=no
-o strict_rfc821_envelopes=yes
#
# Dovecot LDA
dovecot unix – n n – – pipe
flags=DRhu user=vmail:mail argv=/usr/libexec/dovecot/deliver -d ${recipient}
#
# Vacation mail
vacation unix – n n – – pipe
flags=Rq user=vacation argv=/var/spool/vacation/vacation.pl -f ${sender} — ${recipient}
#
[/bash]
続いて、mysqlからいろいろなデータを呼び出すためのconfファイルです。
全部で5本あります。
[bash]
[root@xxxx postfix]# vi /etc/postfix/mysql-relay_domains_maps.cf
hosts = localhost
user = postfix
password = mysqlのpostfixユーザパスワードを記述
dbname = postfix
query = SELECT domain FROM domain WHERE domain=’%s’ AND backupmx = ‘1’
[root@xxxx postfix]# vi /etc/postfix/mysql-virtual_alias_maps.cf
hosts = localhost
user = postfix
password = mysqlのpostfixユーザパスワードを記述
dbname = postfix
query = SELECT goto FROM alias WHERE address=’%s’ AND active = ‘1’
[root@xxxx postfix]# vi /etc/postfix/mysql-virtual_domains_maps.cf
hosts = localhost
user = postfix
password = mysqlのpostfixユーザパスワードを記述
dbname = postfix
query = SELECT domain FROM domain WHERE domain=’%s’ AND backupmx = ‘0’ AND active = ‘1’
[root@xxxx postfix]# vi /etc/postfix/mysql-virtual_mailbox_limit_maps.cf
hosts = localhost
user = postfix
password = mysqlのpostfixユーザパスワードを記述
dbname = postfix
query = SELECT quota FROM mailbox WHERE username=’%s’ AND active = ‘1’
[root@xxxx postfix]# vi /etc/postfix/mysql-virtual_mailbox_maps.cf
hosts = localhost
user = postfix
password = mysqlのpostfixユーザパスワードを記述
dbname = postfix
query = SELECT maildir FROM mailbox WHERE username=’%s’ AND active = ‘1’
[/bash]
次回はpostfixadminの設定について書いていきましょう。
[tmkm-amazon]4274065766[/tmkm-amazon]