> Linux服务器 > mail >

CentOS 简易邮件服务器搭建

CentOS 5.5 64bit 下postfix+dovecot+sasl2+webmail,发信认证,邮件帐号使用系统用户名。

简易邮件服务器并不是专业的搭建一台完整的企业邮箱出来,关于mailscanner,spam,fprot都没有装!包括mysql的认证。



环境:

系统         CentOS 5.5 64bit

企业域名monoedu.com

邮件服务器 mail. monoedu.com

Mail服务器名: mail. monoedu.com

ip:210.14.78.1*

注: DNS必须配置,见其他配置文档



1.       Postfix sasl2 dovecot 安装

[root@mail ~]# yum install postfix cycus-sasl* dovecot



2.       配置

[root@mail ~]# vi /etc/postfix/main.cf

修改内容如下:

myhostname = mail.monoedu.com

mydomain = monoedu.com

myorigin = $mydomain

inet_interfaces = all

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,

mail.$mydomain, www.$mydomain, ftp.$mydomain

mynetworks_style = subnet //指定全网IP,这两个参数设置非常重要(下面)

mynetworks = 127.0.0.0/8, localhost, 210.14.78.0/24 //一般smtp不通都是因为这里没有配置对

relay_domains = $mydestination

home_mailbox = Maildir/  //如果采用系统帐号作为邮件用户名,该目录为帐号下的目录

最后面添加(sasl加密算法支持)

smtpd_sasl_auth_enable = yes

smtpd_sasl_security_options = noanonymous

broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,reject_unauth_destination,permit_mynetworks

smtpd_client_restrictions = permit_sasl_authenticated



从命令行选择可用的 MTA

[root@mail ~]# alternatives --config mta

There are 2 programs which provide 'mta'.

Selection    Command

-----------------------------------------------

*+ 1           /usr/sbin/sendmail.postfix

Enter to keep the current selection[+], or type selection number: 1



[root@mail ~]# vi /etc/sysconfig/saslauthd

SOCKETDIR=/var/run/saslauthd

MECH=shadow //采用系统帐号验证



[root@mail ~]# vi /usr/lib/sasl2/smtpd.conf

修改或者添加

pwcheck_method: saslauthd

mech_list: PLAIN LOGIN

log_level:3



[root@mail ~]# vi /etc/dovecot.conf

修改或者添加

protocols = imap pop3 pop3s

listen = *



[root@mail ~]# /etc/init.d/postfix start|stop|restart

[root@mail ~]# /etc/init.d/dovecot start|stop|restart

[root@mail ~]# /etc/init.d/saslauthd start|stop|restart



3.       设置开机自启

[root@mail ~]#chkconfig –level 345 postfix on

[root@mail ~]#chkconfig –level 345 dovecot on

[root@mail ~]#chkconfig –level 345 saslauthd on



4.       添加帐号

(1)     先新建系统帐号

[root@mail ~]# useradd –s  /bin/nologin –m test

[root@mail ~]# passwd test  //密码 test

(2)     添加邮箱账号

[root@mail ~]# /usr/sbin/testsaslauthd -u test -p test

上面这步所使用的用户名和密码,系统中必须有该用户和对应的密码,否则会报错

返回:ok,successd,执行成功。



5. foxmail 测试

      添加账号:pop3 stmp 都需要设置为域名地址(mail.monoedu.com)



最后就可以通过outlook,foxmail等客户端测试邮件服务器了。

(责任编辑:IT)