| はじめての自宅サーバ構築 - Fedora/CentOS - | Last Update | 2008/07/25 | |
| It opened to 2004/09/19. 当サイトはFedora9で運用しています |
Visitors Pageviews Today(IP/PV) |
3,374,121 12,762,129 1,279/8,751 |
# yum -y install postfix |
設定ファイルの編集
# vi /etc/postfix/main.cf
ホスト名を設定する(ホスト名.ドメイン名)
# INTERNET HOST AND DOMAIN NAMES
#
# The myhostname parameter specifies the internet hostname of this
# mail system. The default is to use the fully-qualified domain name
# from gethostname(). $myhostname is used as a default value for many
# other configuration parameters.
#
myhostname = fedora.kajuhome.com
ドメイン名を設定する
# The mydomain parameter specifies the local internet domain name.
# The default is to use $myhostname minus the first component.
# $mydomain is used as a default value for many other configuration
# parameters.
#
mydomain = kajuhome.com
送信者メールアドレスの@以降をドメイン名にする
# SENDING MAIL
#
# The myorigin parameter specifies the domain that locally-posted
# mail appears to come from. The default is to append $myhostname,
# which is fine for small sites. If you run a domain with multiple
# machines, you should (1) change this to $mydomain and (2) set up
# a domain-wide alias database that aliases each user to
# user@that.users.mailhost.
#
# For the sake of consistency between sender and recipient addresses,
# myorigin also specifies the default domain name that is appended
# to recipient addresses that have no @domain part.
#
myorigin = $mydomain
Postfix が待ち受けるべき全てのネットワークインターフェースを指定
# The inet_interfaces parameter specifies the network interface
# addresses that this mail system receives mail on. By default,
# the software claims all active interfaces on the machine. The
# parameter also controls delivery of mail to user@[ip.address].
#
# See also the proxy_interfaces parameter, for network addresses that
# are forwarded to us via a proxy or network address translator.
#
# Note: you need to stop/start Postfix when this parameter changes.
#
inet_interfaces = all
メールをローカルで受信するドメイン名を指定(ドメイン全体のメールサーバ)
# The mydestination parameter specifies the list of domains that this
# machine considers itself the final destination for.
:
:
# See also below, section "REJECTING MAIL FOR UNKNOWN LOCAL USERS".
#
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
信頼されたネットワークをCIDR (network/mask) 表記で指定(ローカルネットワーク)
# Alternatively, you can specify the mynetworks list by hand, in
# which case Postfix ignores the mynetworks_style setting.
#
# Specify an explicit list of network/netmask patterns, where the
# mask specifies the number of bits in the network part of a host
# address.
#
# You can also specify the absolute pathname of a pattern file instead
# of listing the patterns here. Specify type:table for table-based lookups
# (the value on the table right-hand side is not used).
#
mynetworks = 192.168.1.0/24, 127.0.0.0/8
中継を許可するドメインを指定
# The relay_domains parameter restricts what destinations this system will
# relay mail to. See the smtpd_recipient_restrictions restriction in the
# file sample-smtpd.cf for detailed information.
:
:
# NOTE: Postfix will not automatically forward mail for domains that
# list this system as their primary or backup MX host. See the
# permit_mx_backup restriction in the file sample-smtpd.cf.
#
relay_domains = $mydestination
メールボックス(Maildir)を各ユーザのホームディレクトリに配置
# DELIVERY TO MAILBOX
#
# The home_mailbox parameter specifies the optional pathname of a
# mailbox file relative to a user's home directory. The default
# mailbox file is /var/spool/mail/user or /var/mail/user. Specify
# "Maildir/" for qmail-style delivery (the / is required).
#
home_mailbox = Maildir/
|
新規ユーザを作成した場合、メールボックス(Maildir)を作成する様にする # mkdir /etc/skel/Maildir # chmod 700 /etc/skel/Maildir 既存ユーザのメールボックス(Maildir)を作成する(例:linuxユーザの場合) 一度設定すれば構いません。 # mkdir /home/linux/Maildir 既存ユーザ(linux)のメールボックス(Maildir)のパーミッション・オーナ・グループ変更パーミッション変更 # chmod 700 /home/linux/Maildir オーナ・グループ変更 # chown linux:linux /home/linux/Maildir |
設定ファイルの変更(32bit版の場合)
# vi /usr/lib/sasl2/smtpd.conf
pwcheck_method: auxprop
先頭に「#」を付けてコメント化
#mech_list: plain login
設定ファイルの変更(64bit版の場合)
# vi /usr/lib64/sasl2/smtpd.conf
pwcheck_method: auxprop
先頭に「#」を付けてコメント化
#mech_list: plain login
※:上記の様に「32bit版」と「64bit版」では修正するファイルが違うので注意して下さい。
当方は、この理由で送信できずに悩まされました。
既存ユーザ(linux)のSMTP-Auth(送信認証)パスワード設定する
# saslpasswd2 -u kajuhome.com -c linux
パスワードを入力
Password:
確認入力(上記のパスワードと同じ物を入れる)
Again (for verification):
SMTP-Authユーザの確認
# sasldblistusers2
linux@kajuhome.com: userPassword
sasldb2のパーミッション・グループ変更
初期時、一度設定すれば構いません。
sasldb2の確認
# ll /etc/sasldb2
-rw------- 1 root root 12288 7月 21 05:21 /etc/sasldb2
↑ ↑
グループ読取(なし) グループ(root)
パーミッション変更
# chmod 640 /etc/sasldb2
グループ変更
# chgrp postfix /etc/sasldb2
sasldb2の確認
# ll /etc/sasldb2
-rw-r----- 1 root postfix 12288 7月 21 05:21 /etc/sasldb2
|
sendmailサービスの停止 # chkconfig sendmail off 設定内容を確認 # chkconfig --list sendmail sendmail 0:オフ 1:オフ 2:オフ 3:オフ 4:オフ 5:オフ 6:オフ デフォルトMTAの変更 # alternatives --config mta 2 プログラムがあり 'mta' を提供します。 選択 コマンド ----------------------------------------------- *+ 1 /usr/sbin/sendmail.sendmail 2 /usr/sbin/sendmail.postfix 上記一覧の「postfix」側の番号を入力 Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:2 |
起動時にpostfixを起動する # chkconfig postfix on 設定内容を確認 # chkconfig --list postfix postfix 0:オフ 1:オフ 2:オン 3:オン 4:オン 5:オン 6:オフ 起動時にSMTP-Authを起動する # chkconfig saslauthd on 設定内容を確認 # chkconfig --list saslauthd saslauthd 0:オフ 1:オフ 2:オン 3:オン 4:オン 5:オン 6:オフ |
postfiixを起動する # /etc/rc.d/init.d/postfix start Starting postfix: [ OK ] SMTP-Authを起動する # /etc/rc.d/init.d/saslauthd start saslauthd を起動中: [ OK ] |

aliasファイルの変更
# vi /etc/aliases
#
# Aliases in this file will NOT be expanded in the header from
# Mail, but WILL be visible over networks or from /bin/mail.
#
# >>>>>>>>>> The program "newaliases" must be run after
# >> NOTE >> this file is updated for any changes to
# >>>>>>>>>> show through to sendmail.
#
# Basic system aliases -- these MUST be present.
mailer-daemon: postmaster
postmaster: root
# General redirections for pseudo accounts.
bin: root
daemon: root
:
:
:
# Person who should get root's mail
#root: marc
root宛てをlinuxに変更
root: linux
|