新聞中心
本套郵件系統(tǒng)的搭建,從如何發(fā)郵件到收郵件到認(rèn)證到虛擬用戶虛擬域以及反病毒和反垃圾郵件等都有詳細(xì)的介紹。在搭建過(guò)程中必須的參數(shù)解釋以及原理都有告訴,這樣才能更好地理解郵件系統(tǒng)。

卸載自帶postfix
$ rpm -q postfix
postfix-2.6.6-2.2.el6_1.x86_64
$ rpm -ev postfix --nodeps
環(huán)境準(zhǔn)備
\1. YUM要配置好。
\2. 編譯環(huán)境要配置好。
PS: 這兩步驟如果有問(wèn)題,那么可以看本網(wǎng)站提供的YUM和編譯章節(jié)。
安裝MySQL服務(wù)器
$ yum install mysql-server mysql mysql-devel perl-DBD-MySQL
$ chkconfig mysqld on
$ service mysqld restart
$ rpm -q mysql
mysql-5.1.71-1.el6.x86_64
安裝cyrus-sasl并啟動(dòng)saslauthd服務(wù)
$ yum install cyrus-sasl cyrus-sasl-devel
$ service saslauthd start
$ chkconfig saslauthd on
查看postfix用戶
$ id postfix
uid=89(postfix) gid=89(postfix) 組=89(postfix),12(mail)
發(fā)送郵件的用戶,這里就使用系統(tǒng)自帶的postfix用戶,記住UID:89、GID:89,后面很多地方都要用到這兩個(gè)ID號(hào),如果此ID號(hào)更改了,那么Postfix安裝方面會(huì)有很多目錄權(quán)限都需要更改。
編譯安裝postfix-2.11.7
$ tar zxvf postfix-2.11.7.tar.gz
$ cd postfix-2.11.7
$ make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' 'AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2 -lssl -lcrypto'
$ tar zxvf postfix-2.11.7.tar.gz
$ cd postfix-2.11.7
$ make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' 'AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2 -lssl -lcrypto'
#-DHAS_MYSQL -I/usr/include/mysql //啟用Mysql存儲(chǔ),指定頭文件;
#-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl //啟用SASL(cyrus)認(rèn)證框架;
#-DUSE_TLS //啟用SSL功能;
#AUXLIBS=-L/usr/lib64/mysql -lmysqlclient //找Mysql客戶端庫(kù)文件;
#-lz //壓縮褲文件;
#-lm -L/usr/lib64/sasl2 //模塊文件;
#-lsasl2 -lssl -lcrypto //加密庫(kù)文件;
有以下信息就表示配置成功了
[src/posttls-finger]
cat ../../conf/makedefs.out Makefile.in >Makefile
rm -f Makefile; (cat conf/makedefs.out Makefile.in) >Makefile
$ make
$ make install
按照以下的提示輸入相關(guān)的路徑([]號(hào)中的是缺省值,”]”后的是輸入值,省略的表示采用默認(rèn)值)
install_root: [/]
#指定Postfix安裝目錄,默認(rèn)
tempdir: [/root/postfix-2.11.7] /tmp/postfix
#指定Postfix臨時(shí)文件目錄
config_directory: [/etc/postfix]
#指定Postfix配置文件目錄,默認(rèn)
command_directory: [/usr/sbin]
#指定Postfix二進(jìn)制文件目錄,默認(rèn)
daemon_directory: [/usr/libexec/postfix]
#指定Postfix服務(wù)器進(jìn)程,默認(rèn)
data_directory: [/var/lib/postfix]
#指定Postfix可寫文件目錄,默認(rèn)
html_directory: [no] /var/www/html/postfix
#指定Postfix幫助文件,可以使用web服務(wù)器打開
mail_owner: [postfix]
#指定Postfix屬主,默認(rèn)
mailq_path: [/usr/bin/mailq]
#指定Postfix隊(duì)列程序路徑,默認(rèn)
manpage_directory: [/usr/local/man]
newaliases_path: [/usr/bin/newaliases]
#指定Postfix生成別名命令位置,默認(rèn)
queue_directory: [/var/spool/postfix]
#指定Postfix隊(duì)列目錄,默認(rèn)
readme_directory: [no]
sendmail_path: [/usr/sbin/sendmail]
#指定Postfix客戶端(smtp),默認(rèn)
setgid_group: [postdrop]
#指定Postfix投遞組(默認(rèn)有這個(gè)組,但沒有這個(gè)用戶),默認(rèn)
PS:如果輸入錯(cuò)誤可以按Ctrl+退格鍵刪除字符。
添加SysV風(fēng)格服務(wù)腳本
[root@localhost ~]# vim /etc/rc.d/init.d/postfix
#!/bin/bash
#
# chkconfig: 2345 80 30
# description: Postfix is a Mail Transport Agent, which is the program \
# processname: master
# pidfile: /var/spool/postfix/pid/master.pid
# config: /etc/postfix/main.cf
# config: /etc/postfix/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 3
[ -x /usr/sbin/postfix ] || exit 4
[ -d /etc/postfix ] || exit 5
[ -d /var/spool/postfix ] || exit 6
RETVAL=0
prog="postfix"
start() {
# Start daemons.
echo -n $"Starting postfix: "
/usr/bin/newaliases >/dev/null 2>&1
/usr/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/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/sbin/postfix reload 2>/dev/null 1>&2 && success || failure $"$prog reload"
RETVAL=$?
echo
return $RETVAL
}
abort() {
/usr/sbin/postfix abort 2>/dev/null 1>&2 && success || failure $"$prog abort"
return $?
}
flush() {
/usr/sbin/postfix flush 2>/dev/null 1>&2 && success || failure $"$prog flush"
return $?
}
check() {
/usr/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 $?
# END
[root@localhost ~]# chmod +x /etc/rc.d/init.d/postfix
[root@localhost ~]# chkconfig --add postfix
[root@localhost ~]# chkconfig postfix on
[root@localhost ~]# service postfix start
Postfix相關(guān)命令
# 開啟postfix;
$ postfix start
# 檢查配置;
$ postfix check
# 重新加載;
$ postfix reload
$ postconf [OPTION]
-d:顯示Postfix默認(rèn)的配置;
-n:顯示新修改的配置;
-m:顯示支持的存儲(chǔ)文件類型如hash,mysql等;
-a:顯示支持sasl的客戶端插件類型;
安裝完畢
如果上面沒有使用UID為89的postfix用戶,那么檢查postfix時(shí)就會(huì)報(bào)如下錯(cuò)誤。
$ postfix check
postsuper: fatal: scan_dir_push: open directory defer: Permission denied
原因是一般編譯安裝時(shí),Postfix隊(duì)列目錄/var/spoole/postfix/,下有幾個(gè)目錄會(huì)使用系統(tǒng)自帶postfix的目錄,由于系統(tǒng)默認(rèn)使用postfix(UID:89)用戶給刪除了,所以這些目錄就找不到postfix用戶,開啟時(shí)就會(huì)報(bào)錯(cuò)一些權(quán)限問(wèn)題,把以下幾個(gè)目錄權(quán)限給修改以下就好了,如果還有一些別的目錄一并修改即可。
$ chown -R postfix.root /var/spool/postfix/defer/
$ chown -R postfix.root /var/spool/postfix/deferred/
$ chown -R postfix.root /var/spool/postfix/private/
$ chown -R postfix.postdrop /var/spool/postfix/public/
$ chown -R postfix.postdrop /var/spool/postfix/maildrop/
$ chown -R postfix.root /var/lib/postfix/
Postfix進(jìn)程
master:這條進(jìn)程是 Postfix 郵件系統(tǒng)的大腦,它產(chǎn)生所有其他進(jìn)程。
smtpd:作為服務(wù)器端程序處理所有外部連進(jìn)來(lái)的請(qǐng)求。
smtp:作為客戶端程序處理所有對(duì)外發(fā)起連接的請(qǐng)求。
qmgr:它是 Postfix 郵件系統(tǒng)的心臟,處理和控制郵件隊(duì)列里面的所有消息。
local:這是 Postfix 自有的本地投遞代理MDA,就是它負(fù)責(zé)把郵件保存到郵箱里。
分享題目:Linux下安裝Postfix郵件(二)
當(dāng)前URL:http://www.dlmjj.cn/article/dhcpiid.html


咨詢
建站咨詢
