包安装postfix+sasl+dovecot
dovecot:
Development tools 开发库
server platform Development 服务器端
Desktop platform Development 桌面端
Development Libraries
MySQL:
rpm:
mysql-server
mysql-devel
sasl:
cyrus-sasl-devel.x86_64
cyrus-sasl.x86_64
httpd:
openssl-devel
RHEL自身提供的rpm包
头文件:/usr/include
库文件:/lib,/usr/lib
第三方提供的rpm包:
/usr/local,/opt
/usr/include, /usr/local/include
/etc/ld.so.conf/local.conf
[root@mail ~]# yum -y install mysql-server mysql-devel
[root@mail ~]# service mysqld start
[root@mail ~]# chkconfig mysqld on
[root@www postfix-2.9.15]# groupadd -g 2525 postfix
[root@www postfix-2.9.15]# useradd -g 2525 -u 2525 -s /sbin/nologin -M postfix
[root@www postfix-2.9.15]# groupadd -g 2526 postdrop
[root@www postfix-2.9.15]# useradd -g 2526 -u 2526 -s /sbin/nologin -M postdrop
[root@mail postfix-3.1.1]# hwclock -s
[root@mail postfix-3.1.1]# make makefiles ‘CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -I/usr/include/sasl -DUSE_TLS‘ ‘AUXLIBS=-L/usr//lib64/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2 -lssl -lcrypto‘
make
make install
[root@mail postfix-3.1.1]# vim /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
# 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@mail postfix-3.1.1]# chmod +x /etc/init.d/postfix
[root@mail postfix-3.1.1]# chkconfig --add postfix
[root@mail postfix-3.1.1]# chkconfig postfix on
[root@mail postfix-3.1.1]# newaliases
[root@mail postfix-3.1.1]# ls /etc/aliases.db
/etc/aliases.db
[root@mail postfix-3.1.1]# vim /etc/postfix/main.cf
myhostname = mail.mylinux.com
mydomain = mylinux.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 192.168.1.0/24, 127.0.0.0/8
-----------------------------------------
[root@mail postfix-3.1.1]# yum -y install dovecot
[root@mail postfix-3.1.1]# vim /etc/dovecot/dovecot.conf
protocols = pop3
[root@mail postfix-3.1.1]# service dovecot start
Starting Dovecot Imap: [ OK ]
[root@mail postfix-3.1.1]# netstat -tnulp |grep 110
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 23639/dovecot
tcp 0 0 :::110 :::* LISTEN 23639/dovecot
[root@mail postfix-3.1.1]# yum install mutt -y
mutt:邮件收发
mutt -f pop://admin@mail.mylinux.com
i返回主界面
r恢复
d删除
q退出
y发送
muut -f PROTOCOL ://username@mylinux.com@192.168.1.51 到哪台主机上以哪个用户收发邮件
SASL: cyrus-sasl
saslauthd服务脚本
postfix要使用此脚本需要配置/usr/lib/sasl2/smtpd.conf
添加如下内容:
log_level: 3 (测试才用)
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
[root@mail postfix-3.1.1]# vim /etc/sysconfig/saslauthd
MECH=shadow
[root@mail postfix-3.1.1]# service saslauthd start
[root@mail postfix-3.1.1]# chkconfig saslauthd on
[root@mail postfix-3.1.1]# vim /etc/postfix/main.cf
mynetworks = 127.0.0.0/8
############################CYRUS-SASL############################
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_sasl_path = smtpd
smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!
邮件服务器, 域名,admin@mylinux.com
物理服务器:
一台服务器为多个域收发邮件
mydestination = 所有域
#mydomain = 需要注释掉
使用查找表
myorigin =
虚拟域:
用户别名:
用户帐号:虚拟帐号
本文出自 “运维成长路” 博客,谢绝转载!
原文地址:http://coolcl.blog.51cto.com/4514424/1836880