RHEL5使用postfix配置简单邮件服务器
原创
©著作权归作者所有:来自51CTO博客作者smileliuyb的原创作品,请联系作者获取转载授权,否则将追究法律责任
1.配置服务器的hostname
hostname mail.liuyb.com
vim /etc/hosts
#========================
127.0.0.1 mail.liuyb.com
#========================
vim /etc/sysconfig/network
#========================
HOSTNAME=mail.liuyb.com
#========================
2.建立用户
useradd -s /sbin/nologin liuyb01
echo abc/123 | passwd --stdin liuyb01
useradd -s /sbin/nologin liuyb02
echo abc/123 | passwd --stdin liuyb02
3.安装DNS服务用于解析mail服务器
yum install bind bind-*
vim /var/named/chroot/etc/named.conf
#========================
options{
directory "var/named";
};
zone "liuyb.com." {
type master;
file "liuyb.com.zone";
};
#=========================
cp /usr/share/doc/bind-9.3.6/sample/var/named/named.zero /var/named/chroot/var/named/liuyb.com.zone
vim /var/named/chroot/var/named/liuyb.com.zone
#========================
localhost IN A 127.0.0.1
mail IN A 192.168.18.139
#建立邮件服务器的mx记录并指定优先级为10
liuyb.com. IN MX 10 192.168.18.139
#========================
service named restart
chkconfig named on
4.停止sendmail服务
service sendmail stop
chkconfig sendmail off
5.安装postfix软件包并启动该服务
yum install postfix
service postfix start
chkconfig postfix on
6.配置postfix服务
vim /etc/postfix/main.cf
#===================
myhostname = mail.liuyb.com //邮件服务器的QSDN
mydomain = liuyb.com //邮件服务所在的域
myorigin = $mydomain //邮件服务器本机发送邮件是使用的发件人格式
inet_interfaces = all //邮件服务区监听的网络接口
mydestination = $myhostname,$mydomain //邮件服务器监听的发件人格式
mynetworks = 192.168.0.0/16,127.0.0.0/8 //邮件服务器监听的发件人IP地址
relay_domains = $mydestination,liuyb.com //允许使用邮件服务器作为转发服务器的邮件服务器
alias_maps = hash:/etc/aliases //配置用户别名的文件路径
alias_database = hash:/etc/aliases //配置用户别名的数据库路径
#=====================
service postfix restart
7.测试postfix是否能够使用
telnet mail.liuyb.com 25
mail from:root@mail.liuyb.com
rcpt to:root@mail.liuyb.com
data
subject:hello
hello!
.
quit
#=====================
You have mail in /var/spool/mail/root
#=====================
mail
8.配置cyrus软件包用于安全验证
rpm -qa | grep cyrus
cyrus-sasl-2.*
#yum install cyrus-sasl-2*
#配置安全验证方式为shadow并启动saslauthd服务
vim /etc/sysconfig/saslauthd
#=========================
SOCKETDIR=/var/run/saslauthd
MECH=shadow
FLAGS=
#=========================
/ect/init.d/saslauthd start
chkconfig saslauthd on
9.配置postfix服务使用sasl
vim /etc/postfix/main.cf
#===============================
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = ''
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
broken_sasl_auth_clients = yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous
#=================================
#测试验证服务是否可用
perl -MMIME::Base64 -e 'print encode_base64("liuyb01")'
bGl1eWIwMQ==
perl -MMIME::Base64 -e 'print encode_base64("abc/123")'
YWJjLzEyMw==
telnet mail.liuyb.com 25
ehlo mail.liuyb.com
auth login
334 VXNlcm5hbWU6
bGl1eWIwMQ==
334 UGFzc3dvcmQ6
YWJjLzEyMw==
235 2.0.0 Authentication successful
10.安装dovecot服务用于监听pop3端口
yum install dovecot
vim /etc/dovecot.conf
#==================
protocols = pop3 pop3s //dovecot监听的服务
protocol pop3 {
listen = *:10100 //dovecot监听的端口
}
#===================
service dovecot start
chkconfig dovecot on
11.安装cyrus-imapd软件包用于监听imap,并为邮件服务器提供后台服务
yum install cyrus-imapd cyrus-imapd-devel
#为cyrus用户增加密码用以邮件服务器后台管理
echo abc/123 | passwd --stdin cyrus
vim /etc/postfix/main.cf
#===================
mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp
#===================
/etc/init.d/postfix restart
#启动cyrus服务
/etc/init.d/cyrus-imapd start
chkconfig cyrus-imapd on
12.为用户建立邮箱
cyradm -u cyrus mail.liuyb.com
mail.liuyb.com> cm user.liuyb01 //为liuyb01建立用户邮箱
#mail.liuyb.com> cm user.liuyb01.Send //为用户建立文件夹,send/trash/drafts默认已生成
#mail.liuyb.com> cm user.liuyb01.Trash
#mail.liuyb.com> cm user.liuyb01.Drafts
mail.liuyb.com> setquota user.liuyb01 10240 //建立邮箱配额为10M
mail.liuyb.com> cm user.liuyb02
#mail.liuyb.com> cm user.liuyb02.Send
#mail.liuyb.com> cm user.liuyb02.Trash
#mail.liuyb.com> cm user.liuyb02.Drafts
mail.liuyb.com> setquota user.liuyb02 20480
exit
#查看用户配额
su -l cyrus -c /usr/lib/cyrus-imapd/quota
13.使用邮件客户端(MUA)测试邮件服务器是否可用
~~~~~~~~~~~~~
14.为用户添加别名
vim /etc/aliase
liuyb: liuyb01,liuyb02
#重新加载别名文件
postalias /etc/aliases
postfix reload
#给liuyb@liuyb.com发送邮件,测试该邮件是否同时发送给liuyb01@liuyb.com和liuyb02@liuyb.com
15.使用squirrelmail配置简单的webmail服务
yum install squirrelmail -y
/usr/share/squirrelmail/config/conf.pl //配置squirrelmail
#测试webmail客户端(http://mail.liuyb.com/webmail)
![](https://ucenter.51cto.com/images/noavatar_middle.gif)
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
RHEL5下postfix邮件服务器的安装与详细配置(三)
正在编写,敬请关注
服务器 邮件 休闲 RHEL postfix -
RHEL5中配置SAMBA服务器 收藏
搭建samba服务器实现文件共享SAMBA:Send Message Block,整合了SMB协
Linux 服务器 收藏 SAMBA RHEL5