码迷,mamicode.com
首页 > 其他好文 > 详细

企业邮件系统-Postfix安装使用

时间:2014-08-26 00:26:05      阅读:440      评论:0      收藏:0      [点我收藏+]

标签:des   style   http   os   使用   io   文件   for   ar   

Postfix是目前流行的一套邮件传输代理软件(MTA),其作者Wietst Venema最初开发这套软件时就对总体设计、扩展能力、可用性及系统安全等方面进行了充分的考虑。由于Postfix在稳定、效率、安全和可用性上的优势,使得很多大型的邮件服务提供商都从原有的MTA软件向Postfix过度,而新仅诞生的邮件产品也大多采用了Postfix。网易、Tom和新浪都将原有的Qmail更换为Postfix,可见Postfix在大规模邮件系统中有比较普遍的应用,当然,Postfix也完全适用设计中小型的邮件系统,因为Postfix在保证了效率、安全、扩展等方面优势的同时,还具有配置简单的特点。[比较老的数据了]

 

碎语:

又开始捣腾我比较喜欢的邮件系统了,本文为后面的邮件系统做铺垫,后面在来关联文章树,本文LNMP环境基于LNMP一键安装,请自行通过博客搜索功能搜索该关键词

 

基于CentOS6.5,环境minimal,卸载postfix

[root@ipython ~]# service postfix stop
Shutting down postfix:                                     [  OK  ]
[root@ipython ~]# rpm -e --nodeps postfix

 

安装Postfix

[root@ipython ~]# yum install db4-devel
[root@ipython ~]# tar zxf postfix-2.12-20140801.tar.gz 
[root@ipython ~]# cd postfix-2.12-20140801
####直接编译Makefiles####  ###AUX = 扩展功能[就这理解着吧] -lz = 压缩工具 -lm = 编码支持 ####
####lssl = openssl加密支持  lcrypto = crypto库 ####

###如果你参考了本文,请不要看别的文章,并且最好使用我打包好的免安装LNMP或一键安装LNMP做完一次完整的测试后,再尝试跟着你自己的感觉走哦###
###当然,如果你仍采用了自己的思路并参考了本文,那么请修改下面的依赖文件的路径,欢迎提问###
[root@ipython postfix-2.12-20140801]# make makefiles CCARGS=‘-DHAS_MYSQL -I/software/mysql/include/mysql -DUSE_SASL_AUTH  -DDEF_SERVER_SASL_TYPE=\"dovecot\" -DUSE_TLS -I/software/openssl/include‘ AUXLIBS=‘-L/software/mysql/lib/mysql/ -lmysqlclient -lz -lm -L/software/openssl/lib/ -lssl -lcrypto‘

[root@ipython postfix-2.12-20140801]# make 
###给权限哦###
[root@ipython postfix-2.12-20140801]# chmod a+x postfix-install 
[root@ipython postfix-2.12-20140801]# ./postfix-install -non-interactive install_root=/ tempdir=/tmp config_directory=/etc/postfix command_directory=/usr/sbin/ daemon_directory=/software/postfix data_directory=/var/lib/postfix html_directory=no mail_owner=postfix mailq_path=/usr/bin/mailq manpage_directory=/usr/local/man newaliases_path=/usr/bin/newaliases queue_directory=/var/spool/postfix readme_directory=no sendmail_path=/usr/sbin/sendmail setgia_group=postdrop

 

Postfix自动启动

###postfix 启动脚本可以参考 blfs-bootscripts 包,依赖redhat-lsb,由于太大,这里放弃###

---手动建立---
---------------------/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: /etc/postfix/main.cf
# config: /etc/postfix/master.cf
#
# Based on startup script from Simon J Mudd <sjmudd@pobox.com>
# 25/02/99: Mostly s/sendmail/postfix/g by John A. Martin <jam@jamux.com>
# 23/11/00: Changes & suggestions by Ajay Ramaswamy <ajayr@bigfoot.com>
# 20/01/01: Changes to fall in line with RedHat 7.0 style
# 23/02/01: Fix a few untidy problems with help from Daniel Roesen.

### BEGIN INIT INFO
# Provides: postfix MTA
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop postfix
# Description: Postfix is a Mail Transport Agent, which is the program that 
#              moves mail from one machine to another.
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

RETVAL=0
prog="postfix"
lockfile=/var/lock/subsys/$prog
pidfile=/var/spool/postfix/pid/master.pid

ALIASESDB_STAMP=/var/lib/misc/postfix.aliasesdb-stamp

# Script to update chroot environment
CHROOT_UPDATE=/etc/postfix/chroot-update

status -p $pidfile -l $(basename $lockfile) -b /usr/libexec/postfix/master master >/dev/null 2>&1
running=$?

conf_check() {
    [ -x /usr/sbin/postfix ] || exit 5
    [ -d /etc/postfix ] || exit 6
    [ -d /var/spool/postfix ] || exit 5
}

make_aliasesdb() {
	if [ "$(/usr/sbin/postconf -h alias_database)" == "hash:/etc/aliases" ]
	then
		# /etc/aliases.db may be used by other MTA, make sure nothing
		# has touched it since our last newaliases call
		[ /etc/aliases -nt /etc/aliases.db ] ||
			[ "$ALIASESDB_STAMP" -nt /etc/aliases.db ] ||
			[ "$ALIASESDB_STAMP" -ot /etc/aliases.db ] || return
		/usr/bin/newaliases
		touch -r /etc/aliases.db "$ALIASESDB_STAMP"
	else
		/usr/bin/newaliases
	fi
}

start() {
	[ "$EUID" != "0" ] && exit 4
	# Check that networking is up.
	[ ${NETWORKING} = "no" ] && exit 1
	conf_check
	# Start daemons.
	echo -n $"Starting postfix: "
	make_aliasesdb >/dev/null 2>&1
	[ -x $CHROOT_UPDATE ] && $CHROOT_UPDATE
	/usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure $"$prog start"
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch $lockfile
        echo
	return $RETVAL
}

stop() {
	[ "$EUID" != "0" ] && exit 4
	conf_check
        # 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 $lockfile $pidfile
	echo
	return $RETVAL
}

reload() {
	conf_check
	echo -n $"Reloading postfix: "
	[ -x $CHROOT_UPDATE ] && $CHROOT_UPDATE
	/usr/sbin/postfix reload 2>/dev/null1>&2&& success || failure $"$prog reload"
	RETVAL=$?
	echo
	return $RETVAL
}

abort(){
	conf_check
	/usr/sbin/postfix abort 2>/dev/null1>&2&& success || failure $"$prog abort"return $?}

flush(){
	conf_check
	/usr/sbin/postfix flush 2>/dev/null1>&2&& success || failure $"$prog flush"return $?}

check(){
	conf_check
	/usr/sbin/postfix check 2>/dev/null1>&2&& success || failure $"$prog check"return $?}# See how we were called.case"$1"in
  start)[ $running -eq 0]&&exit0
	start
	;;
  stop)[ $running -eq 0]||exit0
	stop
	;;
  restart|force-reload)
	stop
	start
	;;
  reload)[ $running -eq 0]||exit7
	reload
	;;
  abort)
	abort
	;;
  flush)
	flush
	;;
  check)
	check
	;;
  status)
	status -p $pidfile -l $(basename $lockfile)-b /usr/libexec/postfix/master master
	;;
  condrestart)[ $running -eq 0]||exit0
	stop
	start
	;;*)
	echo $"Usage: $0 {start|stop|restart|reload|abort|flush|check|status|condrestart}"exit2esacexit $?###################################点到为止###################################[root@ipython postfix-2.12-20140801]# chmod 755/etc/init.d/postfix 
[root@ipython postfix-2.12-20140801]# service postfix start
Starting postfix:[  OK  ]

 

» 本文版权采取: BY-NC-SA 协议进行授权,转载注明出处。除IT-Tools、News以及特别标注,本站所有文章均为原创。
» 如果喜欢可以: 点此订阅本站

企业邮件系统-Postfix安装使用

标签:des   style   http   os   使用   io   文件   for   ar   

原文地址:http://www.cnblogs.com/i-it/p/3936162.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!