标签:邮件服务器
邮件服务器是一种用来负责电子邮件收发管理的设备。它比网络上的免费邮箱更安全和高效,因此一直是企业公司的必备设备。
本次实验是由DNS、postfix、dovecot服务共同组建成为邮件服务器
DNS服务如何搭建,我在之前的文章中有过介绍,本篇中就简单介绍。
rpm安装named软件
echo "nameserver 192.168.175.101" >> /etc/resolv.conf
启动服务并测试解析结果
service named start //启动dns服务
rpm安装postfix软件
修改配置文件//etc/postfix/main.cf
inet_interfaces = all //监听服务的IP地址
#inet_interfaces = localhost //注释掉这一行
myhostname = mail.benet.com //邮件服务器主机名
mydomain = benet.com //邮件域名
myorigin = $mydomain //发件人地址邮件域名
mydestination = $mydomain, $myhostname //收件人地址邮件域名
home_mailbox = Maildir/ //邮件存放位置
重启服务
service postfix restart //重启postfix‘服务
rpm安装软件
rpm -ivh /mnt/Packages/dovecot-2.0.9-7.el6.x86_64.rpm
修改配置文件/etc/dovecot/dovecot.conf
protocols = imap pop3 lmtp //开启协议
login_trusted_networks = 192.168.175.0/24 //指定服务器所在网段
修改配置文件/etc/dovecot/conf.d/10-mail.conf,开启邮箱位置及格式
mail_location = maildir:~/Maildir //去掉行首#即可
系统不同脚本编写也不尽相同,仅供参考
#!/bin/bash
#提供邮件服务
#搭建DNS服务
#安装软件
rpm -ivh /mnt/Packages/bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
#配置主配置文件
sed -i ‘s/127.0.0.1/any/‘ /etc/named.conf
sed -i ‘s/localhost;/any;/‘ /etc/named.conf
echo "主配置文件修改成功"
#配置区域配置文件
sed -i ‘24c zone "benet.com" IN {\ntype master;\nfile "benet.com.zone";\nallow-update { none; };\n};‘ /etc/named.rfc1912.zones
echo "区域配置文件修改成功"
#配置区域数据配置文件
cp -p /var/named/named.localhost /var/named/benet.com.zone
sed -i ‘s/@ rname.invalid./benet.com. admin.benet.com./‘ /var/named/benet.com.zone
sed -i ‘s/127.0.0.1/192.168.175.101/‘ /var/named/benet.com.zone
sed -i ‘10c IN MX 5 benet.com.\nmail IN A 192.168.175.101‘ /var/named/benet.com.zone
echo "区域数据配置文件修改成功"
#关闭防火墙及selinux防火墙
service iptables stop
setenforce 0
#启动服务
service named start
echo "nameserver 192.168.175.101" >> /etc/resolv.conf
host mail.benet.com
#修改postfix配置文件
sed -i ‘s/#inet_interfaces = all/inet_interfaces = all/‘ /etc/postfix/main.cf
sed -i ‘s/inet_interfaces = localhost/#inet_interfaces = localhost/‘ /etc/postfix/main.cf
sed -i ‘s/#myhostname = host.domain.tld/myhostname = mail.benet.com/‘ /etc/postfix/main.cf
sed -i ‘s/#mydomain = domain.tld/mydomain = benet.com/‘ /etc/postfix/main.cf
sed -i ‘s/#myorigin = $myhostname/myorigin = $mydomain/‘ /etc/postfix/main.cf
sed -i ‘s/mydestination = $myhostname, localhost.$mydomain, localhost/mydestination = $mydomain, $myhostname/‘ /etc/postfix/main.cf
sed -i ‘s/#home_mailbox = Maildir/home_mailbox = Maildir/‘ /etc/postfix/main.cf
echo "main.cf配置文件修改完成"
service postfix restart
echo "服务启动完成"
#安装dovecot软件
rpm -ivh /mnt/Packages/dovecot-2.0.9-7.el6.x86_64.rpm
#修改dovecot.conf配置文件
sed -i "20c protocols = imap pop3 lmtp" /etc/dovecot/dovecot.conf
sed -i "38c login_trusted_networks = 192.168.175.0/24" /etc/dovecot/dovecot.conf
echo "dovecot.conf配置文件修改完成"
sed -i "24c mail_location = maildir:~/Maildir" /etc/dovecot/conf.d/10-mail.conf
echo "10-mail.conf修改完成"
service dovecot start
#创建测试用账号
groupadd mailusers
useradd -g mailusers -s /sbin/nologin zhangsan
echo "123123" | passwd --stdin zhangsan
useradd -g mailusers -s /sbin/nologin lisi
echo "123123" | passwd --stdin lisi
echo "测试账号zhangsan,lisi创建完成"
标签:邮件服务器
原文地址:http://blog.51cto.com/13643643/2121461