|
在一台linux虚拟机上,安装postfix和dovecot服务器.
1.通过yum安装postfix
a.如果系统存在sendmail,必须先卸载.
b.必须安装dovecot,因为postfix不负责收邮件(110端口).
# yum -y install postfix*
# yum -y install dovecot*
2.编辑配置文件
# vi/etc/postfix/main.cf
myhostname = mail.g.cn
mydomain = g.cn
myorigin = $myhostname
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname , $mydomain
mynetworks = 192.168.1.0/24, 127.0.0.0/8
relay_domains = $mydestination
3.启动服务
# servicesendmail stop
# service postfix restart
# pstree | grep master
# chkconfig postfix on
4.更改系统默认的MTA为postfix
#alternatives--config mta
5.配置dovecot
# vi/etc/dovecot.conf
protocols = imap imaps pop3 pop3s
# service dovecot restart
# netstat -tunpl | grep :110
# chkconfig dovecot on
6.注册2个邮件用户
# useradd user1;useradd user2;
(创建用户后,系统默认给他们创建了邮箱账户,以postfix配置的域名后缀为准)
7.测试:
在本地XP的机器上,通过outlook新建两个账户,互发邮件试试!
(注意: smtp/pop3服务器地址都是postfixserver的ip地址.)
8.测试:
在linux机器上,用mail命令发邮件.
# echo "this is contents" | mail user1@g.cn -s "mail subject"
虚拟域名的配置 通过配置虚拟域名,可以实现多个邮箱域名,发送给 user1@malj.cn 的邮件 == user1@g.cn
1.对 Postfix 的虚拟域名相关选项进行配置。
[iyunv@localhost ~]# vi /etc/postfix/main.cf
virtual_alias_maps= hash:/etc/postfix/virtual //添加一行: 定义虚拟域名转送规则文件
2.定义虚拟域名转送规则。
[iyunv@localhost ~]# vi /etc/postfix/virtual
malj.cn anything //添加这两行: 定义虚拟域名转送规则
@malj.cn @g.cn
[iyunv@localhost ~]# postmap /etc/postfix/virtual //更新虚拟域名规则
3.重新启动Postfix,使设置生效。
[iyunv@localhost ~]# /etc/rc.d/init.d/postfix restart
Shutting down postfix: [ OK ]
Starting postfix: [OK ]
虚拟别名(域)的配置使用虚拟别名域,可以将发给虚拟域的邮件实际投递到真实域的用户邮箱中,以实现群组邮递的功能,即指定一个虚拟邮件地址,任何人发给这个邮件地址的邮件都将由邮件服务器自动转发到真实域中的一组用户的邮箱中。
1.打开/etc/postfix/main.cf ,应确认文件中包含以下两条默认语句:
alias_maps = hash:/etc/aliases //指定含有用户别名定义的文件路径
alias_database = hash:/etc/aliases //指定别名表数据库文件路径
2.编辑/etc/aliases ,添加如下几行:
ceo: boss@g.cn //如果只有一个名单,则表示ceo@g.cn == boss@g.cn
market: market1@g.cn, market2@g.cn //存在多个名单,则market表示这个组的名称
sales: :include: /etc/mail/sales.list //别忘了编辑sales.list文件
//sales组人较多,所以把名单写在一个文件里,格式如下:
sales01, \
sales02, \
sales03, \
sales04, \
sales05
3.执行/usr/sbin/ 目录中的两条命令,使修改生效.
[iyunv@localhost ~]# postalias /etc/aliases //生成Postfix可以读取的数据库文件/etc/aliases.db
[iyunv@localhost ~]# postfixreload //重新加载配置文件
|
|