出典: wiki.nodoka.org
以下の設定でmakeする。
- /usr/local/postfixにインストールする。
- SMTP認証にcyrus-saslを使用する。
- POPにdovecotを使用する。
- mysqlに認証情報をストアする。
- SSL送受信に対応する(openssl)。
- プレーン通信の場合はapopを使用する。
postfix-2.5.2のインストール
cyrus-sasl, dovecot, mysql, opensslが既にインストールされている前提。
groupadd -g 90 postdrop
useradd -u 89 -d /var/spool/postfix -m -s /sbin/nologin postfix
cd /usr/local/src
wget ftp://postfix.get7.biz/postfix/official/postfix-2.5.2.tar.gz
tar xvzf postfix-2.5.2.tar.gz
cd postfix-2.5.2
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
echo "/usr/local/sasl/lib" >> /etc/ld.so.conf
ldconfig
make \
-f Makefile.init makefiles \
'CCARGS= \
-DDEF_CONFIG_DIR=\"/usr/local/postfix/etc\" \
-DUSE_SASL_AUTH \
-DUSE_CYRUS_SASL \
-I/usr/local/sasl/include/sasl \
-DHAS_MYSQL \
-I/usr/local/mysql/include/mysql \
-DUSE_SSL \
-DUSE_TLS \
-I/usr/local/openssl/include' \
'AUXLIBS= \
-L/usr/local/sasl/lib \
-L/usr/local/mysql/lib/mysql \
-L/usr/local/openssl/lib \
-lsasl2 -mysqlclient \
-lz -lm -lssl -lcrypto'
make
make install
→いくつか確認されるので、以下のように設定する。
install_root: [/]
tempdir: [/usr/local/src/postfix-2.5.2]
config_directory: [/usr/local/postfix/etc]
command_directory: [/usr/sbin] /usr/local/postfix/sbin
daemon_directory: [/usr/libexec/postfix] /usr/local/postfix/libexec
data_directory: [/var/lib/postfix] /usr/local/postfix/var/lib
html_directory: [no]
mail_owner: [postfix]
mailq_path: [/usr/bin/mailq] /usr/local/postfix/bin/mailq
manpage_directory: [/usr/local/man] /usr/local/postfix/man
newaliases_path: [/usr/bin/newaliases] /usr/local/postfix/bin/newaliases
queue_directory: [/var/spool/postfix] /usr/local/postfix/var/spool
readme_directory: [no]
sendmail_path: [/usr/sbin/sendmail] /usr/local/postfix/sbin/sendmail
setgid_group: [postdrop]
|
sendmail無効化
chkconfig --list sendmail
chkconfig sendmail off
cd /usr/lib
mv sendmail sendmail.old
ln -s /usr/local/postfix/sbin/sendmail
設定ファイル作成
vi /usr/local/postfix/etc/main.cf
#queue_directory = /var/spool
queue_directory = /usr/local/postfix/var/spool
#command_directory = /sbin
command_directory = /usr/local/postfix/sbin
#daemon_directory = /libexec
daemon_directory = /usr/local/postfix/libexec
#data_directory = /var/lib
data_directory = /usr/local/postfix/var/lib
#myhostname = virtual.domain.tld
myhostname = mail.domain.com
#mydomain = domain.tld
mydomain = domain.com
#myorigin = $mydomain
myorigin = domain.com
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost
#mynetworks = hash:/etc/postfix/network_table
#mynetworks = 168.100.189.0/28, 127.0.0.0/8
mynetworks = 192.168.0.0/24, 127.0.0.0/8
#alias_maps = netinfo:/aliases
alias_maps = hash:/etc/aliases
#home_mailbox = Mailbox
home_mailbox = Maildir/
#mail_spool_directory = /var/spool/mail
mail_spool_directory = /usr/local/postfix/var/spool/mail
#sendmail_path = /sbin/sendmail
sendmail_path = /usr/local/postfix/sbin/sendmail
#newaliases_path = /bin/newaliases
newaliases_path = /usr/local/postfix/bin/newaliases
#mailq_path = /bin/mailq
mailq_path = /usr/local/postfix/bin/mailq
#manpage_directory = /man
manpage_directory = /usr/local/postfix/man
#sample_directory = /etc/postfix
sample_directory = /usr/local/postfix/etc/postfix
transport_maps = hash:/usr/local/postfix/etc/transport
|
vi /usr/local/postfix/etc/master.cf
smtps inet n - n - - smtpd
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
|
特定ドメインのフォワード設定
→ezweb.ne.jp宛てのメールは正引き逆引きが一致しないと拒否されるので、外部のメールサーバにフォワードする。
vi /usr/local/postfix/etc/transport
/usr/local/postfix/sbin/postmap /usr/local/postfix/etc/transport
起動試験と機能確認
/usr/local/postfix/sbin/postfix start
/usr/local/postfix/sbin/postconf -a
/usr/local/postfix/sbin/postconf -m
btree
cidr
environ
hash
mysql
:
:
:
|
postconf -d
起動ファイル作成
vi /etc/init.d/postfix
#!/bin/bash
#
# postfix Postfix Mail Transfer Agent
#
# chkconfig: 2345 80 30
# description: Postfix is a Mail Transport Agent, which is the program \
# that moves mail from one machine to another.
# processname: master
# pidfile: /var/spool/postfix/pid/master.pid
# config: /usr/local/postfix/etc/main.cf
# config: /usr/local/postfix/etc/master.cf
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x /usr/local/postfix/sbin/postfix ] || exit 0
[ -d /usr/local/postfix/etc ] || exit 0
[ -d /usr/local/postfix/var/spool ] || exit 0
RETVAL=0
prog="postfix"
start() {
# Start daemons.
echo -n $"Starting postfix: "
/usr/local/postfix/bin/newaliases >/dev/null 2>&1
/usr/local/postfix/sbin/postfix start 2>/dev/null 1>&2 && success || failure $"$prog start"
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
echo
return $RETVAL
}
stop() {
# Stop daemons.
echo -n $"Shutting down postfix: "
/usr/local/postfix/sbin/postfix stop 2>/dev/null 1>&2 && success || failure $"$prog stop"
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/postfix
echo
return $RETVAL
}
reload() {
echo -n $"Reloading postfix: "
/usr/local/postfix/sbin/postfix reload 2>/dev/null 1>&2 && success || failure $"$prog reload"
RETVAL=$?
echo
return $RETVAL
}
abort() {
/usr/local/postfix/sbin/postfix abort 2>/dev/null 1>&2 && success || failure $"$prog abort"
return $?
}
flush() {
/usr/local/postfix/sbin/postfix flush 2>/dev/null 1>&2 && success || failure $"$prog flush"
return $?
}
check() {
/usr/local/postfix/sbin/postfix check 2>/dev/null 1>&2 && success || failure $"$prog check"
return $?
}
restart() {
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
reload)
reload
;;
abort)
abort
;;
flush)
flush
;;
check)
check
;;
status)
status master
;;
condrestart)
[ -f /var/lock/subsys/postfix ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|abort|flush|check|status|condrestart}"
exit 1
esac
exit $?
|
chkconfig --add postfix
chkconfig postfix on
chkconfig --list postfix
service postfix start